News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Get full path name

Started by starzboy, March 31, 2009, 08:42:28 AM

Previous topic - Next topic

starzboy

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.

jj2007

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

starzboy

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 ?

ToutEnMasm

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


ToutEnMasm

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

donkey

"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

BlackVortex

Quote from: donkey on March 31, 2009, 04:40:13 PM
Try ExpandEnvironmentStrings
That (and ExpandEnvironmentStringsForUser) are a good find  :thumbu

Never heard of those before.