i want to edit the richedit tutorial so it opens a file using the command line. I associate the file with my program, and now i want it to load when clicked on. I defined CommandLine dd 0 ;What's the difference between dd and db? and then i read the command line, pass it to winmain, and display it in a messagebox.
invoke GetCommandLine
mov CommandLine, eax
...
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
...
invoke MessageBox,NULL, ADDR CmdLine,OFFSET AppName,MB_OK
if i just click the executable i get a accented e, accented a, w, and a non-ascii charactor. when i open files it's weird sometimes the same file has the same charactors, sometimes not. It'll be the same, then it won't, then it'll be the first one again. The last char is always non-ascii cause it's the little rectangle. So how am i supposed to open the file? i thought the command line was supposed to give the path of the file, like with notepad you can do "notepad c:\windows\desktop\foo.txt"
Posted on 2001-06-15 21:55:00 by CodinMonkey
invoke GetCommandLine
mov CommandLine, eax
...
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
...

Change that last line into:
 invoke MessageBox, NULL, CommandLine, offset AppName, MB_OK 
Posted on 2001-06-15 23:12:00 by Iczelion
thanks, now it returns the file path, and if a file is clicked on it gives that so it would be like "c:\program.exe" "c:\text.txt" whats the best way to get the file path? should i search for the 3 and 4th qoute's with instr? then how would i get the text is there a mid function since i know where and how long the string is?
Posted on 2001-06-16 12:34:00 by CodinMonkey
That isn't very reliable, as the format of the command line is not always the same (depending on how you execute it, in a command prompt, drop a file on the exe etc.) The most reliable method is using the GetCL function in the m32lib. You can specify a parameter number and it will return that parameter in a buffer. Thomas
Posted on 2001-06-16 14:46:00 by Thomas
can you give me an example? i tried
 ; get any command line filename
invoke PathGetArgs,CommandLine
mov lpFileName, eax

mov esi, eax
lodsb
.if al != 0
cmp al, 34
jne @F          ; jump if no quote

invoke PathUnquoteSpaces,lpFileName
mov lpFileName, eax

@@:

invoke exist,lpFileName
.if eax == 1
invoke openafile,hwnd,lpFileName
.else
invoke MessageBeep,0
.endif
.endif
but anything i try doesn't work. i can't get openafile working in my program either. Whats' '@@:' mean?
Posted on 2001-06-16 16:16:00 by CodinMonkey
@@ is an unnamed label. You use it with jumps to @B (back) and @F (forward): @B jumps to the previous @@, @F jumps to the next @@. You can use @@ multiple times. About the command line: just include masm32.lib and masm32.inc, then call:

invoke GetCL, ArgNum:DWORD , ItemBuffer

ArgNum=0 gives the program name, ArgNum=1 gives the first parameter and so on.. ItemBuffer is a pointer to a buffer to store the parameter. That's all you'll have to do. Thomas
Posted on 2001-06-16 16:23:00 by Thomas
Hi, How would I pass the command line to the running app if it was to have just one instance ? I've tried quite a few things but nothing seems to work right. First I used SendMessage and passed the command line address to the first instance and the first instance would still have the string from startup. Second I tried reading the data with ReadProcessMessage after a notification from the second instance. This seems to work. I say it seems to work because I need to add all files passed to the first instance in allocated memory before I goes further processing them. Somehow it works once - with the second instance - third and forth leave me with nothing in the allocated memory block. I guess I just messed up on writing the strings to memory at the right location. Now, all I wanna know is, would there be an easier way to pass string data between instances ?
Posted on 2001-06-19 14:37:00 by goofee