Hi
i have a string "%windir%/cyz.bat"
how do i process this string to get full path name = C:\WINDOWS\cyz.bat ?
Please help.
include \masm32\include\masm32rt.inc
.data?
buffer db MAX_PATH dup(?)
.code
start:
invoke GetEnvironmentVariable, chr$("windir"), offset buffer, sizeof buffer
MsgBox 0, offset buffer, "%Windir%", MB_OK
exit
end start
that means i will have to remove the "%" and make it "windir" before using GetEnvironmentVariable ?
i will have to cut strings in 2 parts, is there any other way out ?
Hello,
There is also this form,
Quote
;include \masm32\include\advapi32.inc + lib
;include \masm32\include\shell32.inc + lib
; define in ShlObj.h
SHGFP_TYPE_CURRENT equ 0
CSIDL_COMMON_DOCUMENTS equ 02eh
;------- data ----
Htoken dd 0
Chemin db MAX_PATH + 1 dup (0)
titre db "title",0
;----------- code -----------------------
invoke OpenProcessToken,hInstance,TOKEN_READ,addr Htoken
invoke SHGetFolderPath,NULL,CSIDL_SENDTO,Htoken,SHGFP_TYPE_CURRENT,addr Chemin
The CSIDL_... are differents constants who give differents paths.
In this piece of code that you have to modify in your source, "chemin" is the variable where the returned path is written
re,
the ""%windir%/cyz.bat" make a ref to batch file.
In a batch, you can use it directly.
Quote
SET BATCH=%windir%\cyz.bat
Try ExpandEnvironmentStrings (http://msdn.microsoft.com/en-us/library/ms724265(VS.85).aspx)
Quote from: donkey on March 31, 2009, 04:40:13 PM
Try ExpandEnvironmentStrings (http://msdn.microsoft.com/en-us/library/ms724265(VS.85).aspx)
That (and ExpandEnvironmentStringsForUser) are a good find :thumbu
Never heard of those before.