Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Equivalent of SYS(16)
Message
 
À
08/04/1998 01:20:51
Raul Davila
Davila Programming Services
Toa Alta, Porto Rico
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00090128
Message ID:
00090386
Vues:
23
>>Hi,
>>
>>I'm writing a small "splash screen" app using Borland C++ Builder.
>>
>>It works quite well, but I'd like to defend the exe against a user installing my exe in another directory and trying to run it.
>>
>>What I'd like a a procedure in C++ or the Windows API which returns the same information which I get with SYS(16) in Visual FoxPro, so that I can ascertain the location of the exe which is running (the splash screen) and thus find the location of my Visual FoxPro exe (which will be in the same directory).
>>
>>Using the current directory won't necessarily work, as the user could run my exe from a Windows NT command prompt
>>
>>i.e. C:\myappdir\myapp.exe.
>>
>>Best
>>
>>Matt.
>
>Hi Matt:
>
> GetModuleFileName will give you the exact path of exe.
>
> DWORD GetModuleFileName(
> HMODULE hModule, // handle to module to find filename for
> LPTSTR lpFilename, // pointer to buffer for module path
> DWORD nSize // size of buffer, in characters
> );
>
> You can use it in the splash screen exe and look for the VFP app in tha directory.
>
>HTH

Raul,

I overlooked this one. Here's how to get the module and the filename:
DECLARE INTEGER GetModuleFileName IN Win32API;
  INTEGER hModule, STRING @lpFilename, INTEGER nSize
DECLARE INTEGER GetClassLong IN Win32API;
  INTEGER hWnd, INTEGER nIndex
* Get the main window handle from FOXTOOLS
lnhWnd = MainhWnd()
* Get the module handle
lnmodule = GetClassLong(lnhWnd, -16)
* Initialize the parameters
lcfilename = SPACE(265)
lnsize = LEN(lcfilename)
* Get the filename
lnsize = GetModuleFileName(lnmodule, @lcfilename, lnsize)
If lnsize is less than or equal to 1, the function failed. Otherwise, it represents the number of characters in the buffer.

hth,
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform