Hello Everyone,
We distribute a chm help file with our LAN-based FiveWin application. Nothing is installed on the workstations except a desktop launch icon. I know that Microsoft no longer allows chm help files to be opened across a network share for security reasons. From what I've read there are two approaches to supporting network-based chm access. One is to make registry changes for each workstation, and the other is simply to make a copy of the chm file on each workstation's local drive. I think I'm tending toward the second approach because making registry changes on customer's machines just to get our help to work is a bit much. Each time our FiveWin application launches on a workstation it could always check the network share it is running across for a newer chm file than what is on the workstation drive, and update the workstation copy as needed.
Since some network administrators severely limit each user's access to their own machine's hard drive, it would be best to use one of the pre-defined Windows folders meant to store application data files, such as c:\Documents And Settings\. But of course it's not a good idea to hard code folder paths because these folders could be different in the various versions of Windows, or even spelled differently for localized versions of Windows.
Does anyone know if there is a way in FiveWin to query the Window's internals to get literal strings for the pre-defined Windows folders on the current machine? There is a function in Windows called SHGetFolderPath(). If you pass it a constant like CSIDL_COMMON_APPDATA it will return a pointer to a string that is a folder on the local machine which can be used for shared application data. I guess I'm looking for something like that but at the FiveWin/Harbour level.
Thanks!
Supporting CHM files across a network share
- PatrickWeisser
- Posts: 53
- Joined: Fri Mar 23, 2007 4:10 am
- Location: Seattle, WA, USA
- Contact:
Re: Supporting CHM files across a network share
Hi Patrick,
Maybe this helps you with Harbour:PatrickWeisser wrote: I guess I'm looking for something like that but at the FiveWin/Harbour level.
Code: Select all
#define CSIDL_PERSONAL 0x0005
#define SHGFP_TYPE_CURRENT 0
FUNCTION GETDOCUMENTSDIR()
LOCAL sBuffer := SPACE(255)
IF Os_IsWin2000_Or_Later()
DllCall( "shell32.dll", DLL_OSAPI, "SHGetFolderPathA", 0, CSIDL_PERSONAL, 0, SHGFP_TYPE_CURRENT, @sBuffer )
sBuffer := ALLTRIM( STRTRAN( sBuffer, CHR(0), "" ) )
ELSE
sBuffer := "C:\My Documents"
ENDIF
RETURN( sBuffer )
Best Regards,
Ruediger Alich
---
HMG 3.1.3 | FTDN/FWH 13.12 | Harbour 3.2 | BCC/MinGW | Windows XP/Vista/7/8/10 (32/64-Bit), Wine (Linux/Mac) - started 1999 with FW, 1989 with Clipper
Ruediger Alich
---
HMG 3.1.3 | FTDN/FWH 13.12 | Harbour 3.2 | BCC/MinGW | Windows XP/Vista/7/8/10 (32/64-Bit), Wine (Linux/Mac) - started 1999 with FW, 1989 with Clipper
-
- Posts: 824
- Joined: Thu Oct 13, 2005 7:39 am
- Location: Germany
Re: Supporting CHM files across a network share
Patrick,
this may be a solution
http://didierdanse.net/blogs/dev_en/arc ... ntent.aspx
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"MaxAllowedZone"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"UrlAllowList"=\\\\[server name]\\[share name]\\[path];file://\\\\[server name]\\[share name]\\[path];
this may be a solution
http://didierdanse.net/blogs/dev_en/arc ... ntent.aspx
This registry patch may also helpI also experienced this problem, on Windows 7, 64-bit. I had to add the UNC path (\\drive\share) to my Trusted Sites zone and set (in HKLM\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions) MaxAllowedZone to 0x02, not 0x01. I hope that this helps someone else. Source: KB 896054, which has a handy table of which MaxAllowedZone settings enable which zones (higher numbers are more permissive). Another SuperUser question, number 69863, also tells how to turn off the "Open File Security Warning" nag message.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"MaxAllowedZone"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"UrlAllowList"=\\\\[server name]\\[share name]\\[path];file://\\\\[server name]\\[share name]\\[path];
kind regards
Stefan
Stefan
- PatrickWeisser
- Posts: 53
- Joined: Fri Mar 23, 2007 4:10 am
- Location: Seattle, WA, USA
- Contact:
Re: Supporting CHM files across a network share
Hello Ruediger,
Thanks so much for the code -- it looks like what I was thinking of doing. Can you tell me what the value is for the constant DLL_OSAPI? It was not defined in your code sample. Also, DllCall() is undefined, did you mean CallDll()?
Also Stefan thanks very much for your reply. If I decide to go the registry route that looks like a good solution.
-Patrick
Thanks so much for the code -- it looks like what I was thinking of doing. Can you tell me what the value is for the constant DLL_OSAPI? It was not defined in your code sample. Also, DllCall() is undefined, did you mean CallDll()?
Also Stefan thanks very much for your reply. If I decide to go the registry route that looks like a good solution.
-Patrick
Re: Supporting CHM files across a network share
Hi Patrick,
But you can also use this:
It is in the Harbour file \contrib\hbxpp\dll.chPatrickWeisser wrote: Can you tell me what the value is for the constant DLL_OSAPI?
Code: Select all
#define DLL_CDECL 0x08
#define DLL_STDCALL 0x20
#define DLL_SYSTEM 0x04
#if defined( __PLATFORM__WINDOWS )
#define DLL_OSAPI DLL_STDCALL
#elif defined( __PLATFORM__OS2 )
#define DLL_OSAPI DLL_SYSTEM
#else
#define DLL_OSAPI DLL_CDECL
#endif
You have to link e.g. the Harbour file \lib\win\bcc\hbxpp.libPatrickWeisser wrote: Also, DllCall() is undefined, did you mean CallDll()?
But you can also use this:
Code: Select all
FUNCTION GETDOCUMENTSDIR()
LOCAL sBuffer
IF Os_IsWin2000_Or_Later()
sBuffer := HB_GETDOCUMENTSDIR()
ELSE
sBuffer := "C:\My Documents"
ENDIF
RETURN( sBuffer )
#pragma BEGINDUMP
#include <windows.h>
#include <shlobj.h>
#include <hbapi.h>
#define CSIDL_PERSONAL 0x0005
#define SHGFP_TYPE_CURRENT 0
HB_FUNC( HB_GETDOCUMENTSDIR )
{
char sBuffer[ MAX_PATH ];
char *pBuffer=sBuffer;
SHGetFolderPath( 0, CSIDL_PERSONAL, 0, SHGFP_TYPE_CURRENT, sBuffer );
hb_retc( pBuffer );
}
#pragma ENDDUMP
Best Regards,
Ruediger Alich
---
HMG 3.1.3 | FTDN/FWH 13.12 | Harbour 3.2 | BCC/MinGW | Windows XP/Vista/7/8/10 (32/64-Bit), Wine (Linux/Mac) - started 1999 with FW, 1989 with Clipper
Ruediger Alich
---
HMG 3.1.3 | FTDN/FWH 13.12 | Harbour 3.2 | BCC/MinGW | Windows XP/Vista/7/8/10 (32/64-Bit), Wine (Linux/Mac) - started 1999 with FW, 1989 with Clipper
Re: Supporting CHM files across a network share
Windows maintains a number of environment variables which might prove useful. Use the GetEnv() funtion to access these.
eg
GenEnv("ALLUSERSPROFILE")
GetEnv("APPDATA")
GetEnv("CommonProgramFiles")
GetEnv("HOMEDRIVE")+GetEnv("HOMEPATH")
GetEnv("USERPROFILE")
eg
GenEnv("ALLUSERSPROFILE")
GetEnv("APPDATA")
GetEnv("CommonProgramFiles")
GetEnv("HOMEDRIVE")+GetEnv("HOMEPATH")
GetEnv("USERPROFILE")
- PatrickWeisser
- Posts: 53
- Joined: Fri Mar 23, 2007 4:10 am
- Location: Seattle, WA, USA
- Contact:
Re: Supporting CHM files across a network share
Thanks Ruediger, that second code sample worked perfectly with the FiveWin/Harbour install I have. It's exactly what I was looking for!
And Kennedy thanks for your suggestion about using the GetEnv() function -- that also works great!
-Patrick
And Kennedy thanks for your suggestion about using the GetEnv() function -- that also works great!
-Patrick
Re: Supporting CHM files across a network share
P,
Can try this other way...
Can try this other way...
Code: Select all
#include "FiveWin.ch"
*--------------
FUNCTION Main()
*--------------
LOCAL oShell := TOleAuto():New( "WScript.Shell" )
msginfo( oShell:SpecialFolders( 'DESKTOP' ) )
msginfo( oShell:SpecialFolders( 'MYDOCUMENTS' ) )
RETU .T.
Salutacions, saludos, regards
"...programar es fácil, hacer programas es difícil..."
https://modharbour.app
https://modharbour.app/compass
https://forum.modharbour.app
"...programar es fácil, hacer programas es difícil..."
https://modharbour.app
https://modharbour.app/compass
https://forum.modharbour.app