There are two ways to get your path.
The first method is done using app.path and app.exename. code show as below:
StrPath = IIF (right (app.path, 1) = "/", app.path, app.path & ") & app.exename &" .exe "
Does this seem to be more chaotic? Nothing, rewriting so is more clear. code show as below:
If Right (app.path, 1) = "/" THEN STRPATH1 = App.Path & App.Exename & ".exe" else strpath1 = app.path "END IF
This seems to be more clear.
The second method uses the API function, the function name is getModuleFileName, the function declaration:
Declare function getModuleFileName Lib "kernel32" Alias "getModuleFileNamea" (Byval HModule As String, Byval nsize as long) AS Long
Note: Gets a full path name of a loaded template Return value: long, if the execution is successful, return to the actual number of characters copied to LPFileName; zero means failed. Parameter table parameter type and means HMODule long, a handle of a module. It can be a DLL module, or an application's instance handle LPFileName String, specify a string buffer, the path name to abort the file with the NULL character in which the file is accommodated, the hModule module is loaded from this file. Nsize Long, Maximum number of characters loaded into the buffer lpfilename
The function getModuleFileName is over. Then continue our second approach. code show as below:
DIM STRPATH AS STRING 'STRPATH Saves Self - StrPath = Space (256) GetModuleFileName 0, STRPATH, 256
This is two ways to get the path of itself.
I am a newbie, please enlighten me!