1.
Getcurrentdirectory
Get Current Directory
2.
Getmodulefilename
Obtain the complete path
+ Pathremovefilespec
Separate pure path
. 386
. Model
Flat, stdcall
Option Casemap: None
Include
Windows. inc
Include
Kernel32.inc
Include
User32.inc
Includelib
Kernel32.lib
Includelib
User32.lib
Include
Shlwapi. inc
; Pathremovefilespec
Use
Includelib
Shlwapi. Lib
. Data
Hinstance
Dd
?
Szprofilename
DB
Max_path DUP (?)
Szfilename
DB
'/Test. ini', 0
;
The file name is prefixed.
/
. Code
Start:
Invoke
Getmodulehandle, null
MoV
Hinstance, eax
Invoke
Getcurrentdirectory, max_path, ADDR szprofilename
;
Method 1
MoV
EDI, offset szprofilename
Invoke
Lstrlen, EDI
MoV
ECX, offset szfilename
; Ini
File Name
. If
Byte PTR [EDI + eax-1] = '/'
;
The last character of the current path is
/
?
INC
ECX
;
Yes, skip
Ini
File Name
/
To prevent the generation of two
//
. Endif
Invoke
Lstrcat, EDI, ECx
;
Link composition completion path name
;
Note This method
Invoke
MessageBox, null, EDI, null, mb_ OK
Invoke
Getmodulefilename, null, ADDR szprofilename, max_path
;
Method 2
Invoke
Pathremovefilespec, ADDR szprofilename
MoV
EDI, offset szprofilename
Invoke
Lstrlen, EDI
MoV
ECX, offset szfilename
. If
Byte PTR [EDI + eax-1] = '/'
INC
ECX
. Endif
Invoke
Lstrcat, EDI, ECx
Invoke
MessageBox, null, EDI, null, mb_ OK
Invoke
Exitprocess, null
End start