Supporting CHM files across a network share

Supporting CHM files across a network share

Postby PatrickWeisser » Wed Feb 09, 2011 9:26 am

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!
User avatar
PatrickWeisser
 
Posts: 53
Joined: Fri Mar 23, 2007 4:10 am
Location: Seattle, WA, USA

Re: Supporting CHM files across a network share

Postby IBTC » Wed Feb 09, 2011 10:11 am

Hi Patrick,

PatrickWeisser wrote:I guess I'm looking for something like that but at the FiveWin/Harbour level.


Maybe this helps you with Harbour:

Code: Select all  Expand view  RUN

#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
User avatar
IBTC
 
Posts: 103
Joined: Sat Oct 18, 2008 8:13 pm
Location: Stuttgart, Germany

Re: Supporting CHM files across a network share

Postby StefanHaupt » Wed Feb 09, 2011 1:05 pm

Patrick,

this may be a solution
http://didierdanse.net/blogs/dev_en/archive/2009/09/08/windows-7-how-to-display-chm-content.aspx

I 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.


This registry patch may also help

[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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Supporting CHM files across a network share

Postby PatrickWeisser » Wed Feb 09, 2011 4:17 pm

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
User avatar
PatrickWeisser
 
Posts: 53
Joined: Fri Mar 23, 2007 4:10 am
Location: Seattle, WA, USA

Re: Supporting CHM files across a network share

Postby IBTC » Wed Feb 09, 2011 4:44 pm

Hi Patrick,

PatrickWeisser wrote:Can you tell me what the value is for the constant DLL_OSAPI?


It is in the Harbour file \contrib\hbxpp\dll.ch

Code: Select all  Expand view  RUN
#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


PatrickWeisser wrote:Also, DllCall() is undefined, did you mean CallDll()?


You have to link e.g. the Harbour file \lib\win\bcc\hbxpp.lib

But you can also use this:

Code: Select all  Expand view  RUN

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
User avatar
IBTC
 
Posts: 103
Joined: Sat Oct 18, 2008 8:13 pm
Location: Stuttgart, Germany

Re: Supporting CHM files across a network share

Postby kennedyv » Wed Feb 09, 2011 5:01 pm

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")
User avatar
kennedyv
 
Posts: 8
Joined: Fri Nov 23, 2007 9:19 pm

Re: Supporting CHM files across a network share

Postby PatrickWeisser » Wed Feb 09, 2011 6:36 pm

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
User avatar
PatrickWeisser
 
Posts: 53
Joined: Fri Mar 23, 2007 4:10 am
Location: Seattle, WA, USA

Re: Supporting CHM files across a network share

Postby Carles » Wed Feb 09, 2011 7:38 pm

P,

Can try this other way...

Code: Select all  Expand view  RUN
#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..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1139
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 38 guests