The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: slovach on March 21, 2008, 08:14:48 AM

Title: prepend a string
Post by: slovach on March 21, 2008, 08:14:48 AM
Say I want to prepend what returns from something GetCurrentDirectory to another string? What's a good way to go about this?
Title: Re: prepend a string
Post by: u on March 21, 2008, 08:18:48 AM
:D appending it the other way, for instance.
Title: Re: prepend a string
Post by: jj2007 on March 21, 2008, 08:47:19 AM
include \masm32\include\masm32rt.inc

.data?
buffer   db MAX_PATH dup (?)

.code

AppName   db   "Test app", 0
MyFile   db   "\MyParas.ini", 0

start:
   invoke GetCurrentDirectory, MAX_PATH-12, addr buffer
   invoke lstrcat, addr buffer, addr MyFile
   invoke MessageBox, NULL, addr buffer, addr AppName, MB_OK
   invoke ExitProcess, 0
end start
Title: Re: prepend a string
Post by: slovach on March 21, 2008, 08:33:40 PM
That was exactly what I was looking for, thanks.
Title: Re: prepend a string
Post by: herge on April 01, 2008, 11:29:55 AM
 Hi slovach:

You can also try:
The API GetModuleFileName
invoke GetModuleFileName,hInst,addr buffer,260]
Title: Re: prepend a string
Post by: evlncrn8 on April 01, 2008, 02:40:08 PM
GetModuleFileName does NOT always give you the working directory.. especially if the working directory was set by a shortcut/lnk...
and you also have to trim the exe name from it...