问题描述
我试图找出如何抓住我的程序启动目录。我使用C和有机会获得GLib的。在Linux方面,它很容易,g_get_current_directory一旦程序启动,并存储供以后使用该值。我试图在Windows上使用,但g_get_current_directory返回相同的方法,无论%APPDATA%解析到。
I am trying to figure out how to grab the start directory for my program. I am using C and have access to GLib. On the Linux side it is easy, g_get_current_directory as soon as the program is launched, and store this value for later use. I tried using the same method on windows but g_get_current_directory returns whatever %APPDATA% resolves to.
这是我怎么能抢起始目录使用C?任何想法
Any ideas on how I can grab the starting directory using C?
谢谢,
推荐答案
哎呀,找到了解决办法。如果你有机会到巧舌如簧,只需使用:
Oops, found the solution. If you have access to glib, simply use:
gchar * g_win32_get_package_installation_directory_of_module(gpointer HMODULE);
gchar* g_win32_get_package_installation_directory_of_module(gpointer hmodule);
如果HMODULE为NULL,则它会返回目录为.exe文件
If hmodule is NULL then it will return the dir for the .exe
这篇关于可执行的启动目录的绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!