• 9854阅读
  • 2回复

QT中GetModuleFileName函数怎么用? [复制链接]

上一主题 下一主题
离线lvyankun
 
只看楼主 正序阅读 楼主  发表于: 2009-08-03
想用GetModuleFileName获取EXE的运行路径,但是每次都只能得到盘符......
离线lvyankun
只看该作者 2楼 发表于: 2009-08-03
想用WINDOWS的API。
开始的时候用的是GetModuleFileName,不行,改成GetModuleFileNameA可以了,可能是因为第二个参数的原因。
谢谢楼上啦
离线dbzhang800

只看该作者 1楼 发表于: 2009-08-03
你应该用这个吧!

QString QCoreApplication::applicationDirPath ()   [static]

Returns the directory that contains the application executable.

For example, if you have installed Qt in the C:\Trolltech\Qt directory, and you run the regexp example, this function will return "C:/Trolltech/Qt/examples/tools/regexp".

On Mac OS X this will point to the directory actually containing the executable, which may be inside of an application bundle (if the application is bundled).

Warning: On Linux, this function will try to get the path from the /proc file system. If that fails, it assumes that argv[0] contains the absolute file name of the executable. The function also assumes that the current directory has not been changed by the application.

See also applicationFilePath().
快速回复
限100 字节
 
上一个 下一个