i was wondering if someone can help me get the path stored in an environment variable. For instance i was the path of %USERPROFILE% so i can create a desktop shortcut. My idea would be that %USERPROFILE% will make it easy with the different OS's since xp uses documents and settings but on vista it has a users folder instead. %USERPROFILE%\desktop does open the desktop folder on my vista pc and if i remember right that should work on xp aswell.
Jackal,
If I understand your question, I believe to get what you
want, a simple call to the c runtime function getenv will
do it.
As they say "pardon my French" (meaning this is in Fasm).
;**************
;* GetEnv.asm *
;**************
format pe gui 4.0
entry start
include 'win32ax.inc'
.code
proc start
cinvoke getenv,"USERPROFILE"
invoke MessageBox,0,eax,"GetEnv: UserProfile",0
invoke ExitProcess,0
endp
data import
library kernel32,'kernel32.dll',\
user32,'user32.dll',\
msvcrt,'msvcrt.dll'
import kernel32,\
ExitProcess,'ExitProcess'
import user32,\
MessageBox,'MessageBoxA'
import msvcrt,\
getenv,'getenv'
end data
Check this site to see if the OS you
want the environment variable for
is supported:
http://www.scriptlogic.com/support/CustomScripts/environmentVariableReference.html
Also see:
DWORD WINAPI GetEnvironmentVariable(
LPCTSTR lpName,
LPTSTR lpBuffer,
DWORD nSize
);
in kernel32 if you don't want to use msvcrt.
thanks.. while you posted that last message i tried getenv but it didnt work right away but led me to GetEnvironmentVariable and i was able to get it working. Again thanks and ill check out that site.
Have a look at SHGetSpecialFolderPath as well - works with 95/NT4 (with IE4) and 98/2000 or better
I do happen to like that better as %USERPROFILE% is only valid in 2000 or better where i can use this in pre windows versions and it does work on my vista aswell even though vista has changed from csidl to knowfolderid's but allows for the csidl id for backwards compatibility.
Invoke SHGetSpecialFolderPath, hWnd, addr DeskBuffer, CSIDL_DESKTOPDIRECTORY, 0
Thanks for the info... Worked like a charm aswell :)