å¨æ«åä¸ä¸ªålinuxå¹³å°å¼åçæå讨论äºä¸å¦ä½è·åå½åè¿è¡ç¨åºæå¨çç®å½çé®é¢ãé¦å
æå¨è¿éç®åçä»ç»ä¸è¿è¡çåºç¨ç¨åºçå½åå·¥ä½ç®å½åè¿è¡åºç¨ç¨åºæå¨çç®å½çåºå«ï¼
å½åå·¥ä½ç®å½ (Current Working Directory)
ä¸è¬æ¥è¯´ï¼æ¯ä¸ªè¿ç¨é½æä¸ä¸ªä¸ä¹ç¸å
³èçå级æ件系ç»(hierarchical file system)ä¸çç®å½ï¼ç§°ä¹ä¸ºè¯¥è¿ç¨çå½åå·¥ä½ç®å½ãå¦æç¨åºåè¿å
¥mainå
¥å£å¤çæ¶åï¼å½åå·¥ä½ç®å½å
¶å®å°±æ¯ç¨åºå¯å¨çç®å½ï¼ä½æ¯å½åå·¥ä½ç®å½æ¯å¯ä»¥éè¿ç¨åºè¿è¡è®¾ç½®æè
éçOpenFileDialogãSaveFileDialogç对象æç¡®å®çç®å½èæ¹åãæ以使ç¨çæ¶åè¦å°å¿ã
åºç¨ç¨åºæå¨çç®å½
该è¿ç¨ä»ä¸å¯å¨çç®å½ï¼å³ç¨åºæ件èªèº«æå¨çç®å½ã
æ以ï¼å½åå·¥ä½ç®å½åç¨åºæå¨çç®å½å¯ä»¥ä¸åã
Windowsè·åç¨åºå
¨è·¯å¾çæ¥å£æ¯ï¼GetModuleFileName
C Run-Time åºè·åç¨åºå
¨è·¯å¾æ¥å£æ¯ï¼_get_tpgmptr
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char a[MAX_PATH] = {0};
WCHAR *p = NULL;
_get_tpgmptr(&p);
wcout << p << endl;
}
温馨提示:答案为网友推荐,仅供参考