首页
社区
课程
招聘
[求助]请教,GetCommandLine函数为什么在两种情况下获得的文件名不同?
发表于: 2007-1-16 20:51 6960

[求助]请教,GetCommandLine函数为什么在两种情况下获得的文件名不同?

2007-1-16 20:51
6960
我用MASM32写了一个小程序,里面用GetCommandLine来取EXE文件的路径,编译后在QEDITOR里面选菜单RUN PROGRAME运行能得到正确的路径,但在资源管理器里双击EXE文件执行就得不到正确的文件路径,请问是怎么回事?

用GETMODULEFILENAME没有什么问题。。。

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
免费 0
支持
分享
最新回复 (6)
雪    币: 222
活跃值: (10)
能力值: ( LV8,RANK:130 )
在线值:
发帖
回帖
粉丝
2
CommandLine可以是空的,第一个参数也可以不是程序路径
2007-1-16 22:15
0
雪    币: 796
活跃值: (370)
能力值: ( LV9,RANK:380 )
在线值:
发帖
回帖
粉丝
3


获取程序路径,貌似用GetModuleFileName吧?
2007-1-16 23:42
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
Winker :
谢谢
命令行函数得到的第一个字符串,就是该EXE文件的文件名呀
GetModuleFileName当然是可以的,我只是想知道GetCommandLine为什么两种情况得到的文件名不一样,你试一试看。
2007-1-17 15:17
0
雪    币: 101
活跃值: (12)
能力值: ( LV12,RANK:210 )
在线值:
发帖
回帖
粉丝
5
BOOL CreateProcess(
  LPCTSTR lpApplicationName,                 // name of executable module
  LPTSTR lpCommandLine,                      // command line string
  LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
  LPSECURITY_ATTRIBUTES lpThreadAttributes,  // SD
  BOOL bInheritHandles,                      // handle inheritance option
  DWORD dwCreationFlags,                     // creation flags
  LPVOID lpEnvironment,                      // new environment block
  LPCTSTR lpCurrentDirectory,                // current directory name
  LPSTARTUPINFO lpStartupInfo,               // startup information
  LPPROCESS_INFORMATION lpProcessInformation // process information
);

lpCommandLine
[in, out] Pointer to a null-terminated string that specifies the command line to execute.
Windows NT/2000/XP: The Unicode version of this function, CreateProcessW, will fail if this parameter is a const string.

The lpCommandLine parameter can be NULL. In that case, the function uses the string pointed to by lpApplicationName as the command line.

If both lpApplicationName and lpCommandLine are non-NULL, *lpApplicationName specifies the module to execute, and *lpCommandLine specifies the command line. The new process can use GetCommandLine to retrieve the entire command line. C runtime processes can use the argc and argv arguments. Note that it is a common practice to repeat the module name as the first token in the command line.

If lpApplicationName is NULL, the first white-space ? delimited token of the command line specifies the module name. If you are using a long file name that contains a space, use quoted strings to indicate where the file name ends and the arguments begin (see the explanation for the lpApplicationName parameter). If the file name does not contain an extension, .exe is appended. Therefore, if the file name extension is .com, this parameter must include the .com extension. If the file name ends in a period (.) with no extension, or if the file name contains a path, .exe is not appended. If the file name does not contain a directory path, the system searches for the executable file in the following sequence:

知道为什么了吗
2007-1-17 22:55
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
谢谢jjnet!
好象有一点知道了。。。我自己用 CreateProcess来试一下。
2007-1-18 09:58
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
谢谢jjnet!
好象有一点知道了。。。我自己用 CreateProcess来试一下。
2007-1-18 10:51
0
游客
登录 | 注册 方可回帖
返回
//