本文整理匯總了C++中GetCurrentDirectory函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetCurrentDirectory函數的具體用法?C++ GetCurrentDirectory怎麽用?C++ GetCurrentDirectory使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetCurrentDirectory函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: WDL_ChooseFileForSave
bool WDL_ChooseFileForSave(HWND parent,
const char *text,
const char *initialdir,
const char *initialfile,
const char *extlist,
const char *defext,
bool preservecwd,
char *fn,
int fnsize,
const char *dlgid,
void *dlgProc,
#ifdef _WIN32
HINSTANCE hInstance
#else
struct SWELL_DialogResourceIndex *reshead
#endif
)
{
char cwd[2048];
GetCurrentDirectory(sizeof(cwd),cwd);
#ifdef _WIN32
char temp[4096];
memset(temp,0,sizeof(temp));
if (initialfile) lstrcpyn_safe(temp,initialfile,sizeof(temp));
WDL_fixfnforopenfn(temp);
#ifdef WDL_FILEBROWSE_WIN7VISTAMODE
{
Win7FileDialog fd(text, 1);
if(fd.inited())
{
fd.addOptions(FOS_DONTADDTORECENT);
//vista+ file open dialog
char olddir[2048];
GetCurrentDirectory(sizeof(olddir),olddir);
fd.setFilterList(extlist);
if (defext)
{
fd.setDefaultExtension(defext);
int i = 0;
const char *p = extlist;
while(*p)
{
if(*p) p+=strlen(p)+1;
if(!*p) break;
if(stristr(p, defext))
{
fd.setFileTypeIndex(i+1);
break;
}
i++;
p+=strlen(p)+1;
}
}
fd.setFolder(initialdir?initialdir:olddir, 0);
if(initialfile)
{
//check for folder name
if (WDL_remove_filepart(temp))
{
//folder found
fd.setFolder(temp, 0);
fd.setFilename(temp + strlen(temp) + 1);
}
else
fd.setFilename(*temp ? temp : initialfile);
}
fd.setTemplate(hInstance, dlgid, (LPOFNHOOKPROC)dlgProc);
if(fd.show(parent))
{
//ifilesavedialog saves the last folder automatically
fd.getResult(fn, fnsize);
if (preservecwd) SetCurrentDirectory(olddir);
return true;
}
if (preservecwd) SetCurrentDirectory(olddir);
return NULL;
}
}
#endif
OPENFILENAME l={sizeof(l),parent, hInstance, extlist, NULL,0, 0, temp, sizeof(temp)-1, NULL, 0, initialdir&&initialdir[0] ? initialdir : cwd, text,
OFN_HIDEREADONLY|OFN_EXPLORER|OFN_OVERWRITEPROMPT,0,0,defext, 0, (LPOFNHOOKPROC)dlgProc, dlgid};
if (hInstance&&dlgProc&&dlgid) l.Flags |= OFN_ENABLEHOOK|OFN_ENABLETEMPLATE|OFN_ENABLESIZING;
if (preservecwd) l.Flags |= OFN_NOCHANGEDIR;
if (!GetSaveFileName(&l)||!temp[0])
{
if (preservecwd) SetCurrentDirectory(cwd);
return false;
}
if (preservecwd) SetCurrentDirectory(cwd);
//.........這裏部分代碼省略.........
示例2: SetWindowText
//初始化函數
BOOL CDlgRegister::OnInitDialog()
{
__super::OnInitDialog();
//設置標題
SetWindowText(TEXT("帳號注冊"));
//限製輸入
((CComboBox *)(GetDlgItem(IDC_ACCOUNTS)))->LimitText(NAME_LEN-1);
((CEdit *)(GetDlgItem(IDC_PASSWORD)))->LimitText(PASS_LEN-1);
((CEdit *)(GetDlgItem(IDC_PASSWORD2)))->LimitText(PASS_LEN-1);
m_LineRegWeb.SetHyperLinkUrl(TEXT("http://www.dc173.com"));
m_LineMainPage.SetHyperLinkUrl(TEXT("http://www.dc173.com"));
m_LinePassWord.SetHyperLinkUrl(TEXT("http://www.dc173.com"));
//加載頭像
g_GlobalUnits.m_UserFaceRes->FillImageList(m_ImageList);
m_FaceSelect.SetImageList(&m_ImageList);
//插入頭像
COMBOBOXEXITEM Item;
ZeroMemory(&Item,sizeof(Item));
Item.mask=CBEIF_IMAGE|CBEIF_SELECTEDIMAGE;
for (int i=g_GlobalUnits.m_UserFaceRes->GetFaceCount()-1;i>=0;i--)
{
Item.lParam=i;
Item.iImage=i;
Item.iSelectedImage=i;
m_FaceSelect.InsertItem(&Item);
}
//用戶性別
BYTE cbGender[]={/*GENDER_NULL,*/GENDER_BOY,GENDER_GIRL};
LPCTSTR pszGender[]={/*TEXT("保密"),*/TEXT("男性"),TEXT("女性")};
CComboBox * pComboBox=(CComboBox *)GetDlgItem(IDC_GENDER);
//用戶性別
for (int i=0;i<CountArray(cbGender);i++)
{
int nItem=pComboBox->InsertString(i,pszGender[i]);
pComboBox->SetItemData(nItem,cbGender[i]);
}
pComboBox->SetCurSel(0);
//設置頭像
m_wFaceID=rand()%g_GlobalUnits.m_UserFaceRes->GetFaceCount();
m_FaceSelect.SetCurSel(m_wFaceID);
//獲取目錄
TCHAR szPath[MAX_PATH]=TEXT("");
GetCurrentDirectory(sizeof(szPath),szPath);
//讀取配置
TCHAR szFileName[MAX_PATH]=TEXT("");
_snprintf(szFileName,sizeof(szFileName),TEXT("%s\\Spreader.ini"),szPath);
//讀取推薦人
TCHAR szSpreader[NAME_LEN]=TEXT("");
GetPrivateProfileString(TEXT("SpreaderInfo"),TEXT("SpreaderName"),TEXT(""),szSpreader,CountArray(szSpreader),szFileName);
//設置名字
if (szSpreader[0]!=0)
{
SetDlgItemText(IDC_SPREADER,szSpreader);
((CEdit *)GetDlgItem(IDC_SPREADER))->SetReadOnly();
}
return TRUE;
}
示例3: ReadVOIPConfig
void ReadVOIPConfig(void)
{
int i;
DJ_S8 sep[] = {","};
char buf[MAX_PREFIX][256] = {(0,0)};
char *p = NULL;
char *pBuf = NULL;
char chTmp[MAX_SEC]= {0};
char strTmp[256]= {0};
/*read sysconfig from PBXGetWay.ini*/
GetCurrentDirectory(MAX_FILE_NAME_LEN-32, cfg_IniName);
strcat(cfg_IniName, cfg_IniShortName);
GetPrivateProfileString("XMSCONFIG", "XMSIP", "192.168.10.132", cfg_ServerID.m_s8ServerIp, sizeof(cfg_ServerID.m_s8ServerIp), cfg_IniName);
cfg_ServerID.m_u32ServerPort = GetPrivateProfileInt("XMSCONFIG", "XMSPORT", 9000, cfg_IniName);
GetPrivateProfileString("XMSCONFIG","XMSUSER","",cfg_ServerID.m_s8UserName,sizeof(cfg_ServerID.m_s8UserName),cfg_IniName);
GetPrivateProfileString("XMSCONFIG","XMSPASSWORD","",cfg_ServerID.m_s8UserPwd,sizeof(cfg_ServerID.m_s8UserPwd),cfg_IniName);
g_u8UnitID = GetPrivateProfileInt("XMSCONFIG", "UNITID", 40, cfg_IniName);
/*read work moduleID form PBXGetWay.ini*/
GetPrivateProfileString("XMSCONFIG", "VOIPWORK","",cfg_chPartWorkModuleID, sizeof(cfg_chPartWorkModuleID), cfg_IniName);
strncpy(strTmp, cfg_chPartWorkModuleID, sizeof(strTmp));
SplitStr2Int(strTmp, ",", cfg_iVoipWorkMod);
GetPrivateProfileString("XMSCONFIG", "DIGTRKWORK","",cfg_chPartWorkModuleID, sizeof(cfg_chPartWorkModuleID), cfg_IniName);
strncpy(strTmp, cfg_chPartWorkModuleID, sizeof(strTmp));
SplitStr2Int(strTmp, ",", cfg_iDTrkWorkMod);
/*read ip pool from PBXGetWay.ini*/
cfg_IpPool = GetPrivateProfileInt("IPPOOL", "ITEMCNT", 1, cfg_IniName);
My_IpPoolItem(cfg_IpPool);
My_IpPool(cfg_IpPool);
for (i = 0; i < cfg_IpPool; i++)
{
if (pIpPool[i] != NULL)
GetPrivateProfileString("IPPOOL",pIpPoolItem[i] , "", (LPTSTR )pIpPool[i], 20, cfg_IniName);
}
pubSendRTPDTMFType = GetPrivateProfileInt("RTPDTMF","SENDTYPE",1,cfg_IniName);
pubDebug = GetPrivateProfileInt("XMSCONFIG","DEBUGON",0,cfg_IniName);
GetPrivateProfileString("OUTBONDVOIP","VOIP_ADDRESS","",pubOutVoipAddress,sizeof(pubOutVoipAddress),cfg_IniName);
pubOutVoipPort=GetPrivateProfileInt("OUTBONDVOIP","VOIP_PORT",5060,cfg_IniName);
//VOIP輸出規則
pubVoipRule=GetPrivateProfileInt("VOIPRULE","OUTRULE",0,cfg_IniName);
//日誌開關
bLog = GetPrivateProfileInt("LOG", "LOG", 0, cfg_IniName);
// GetPrivateProfileString("DIALRULE", "DIALRULE", "", CodeRule, sizeof(CodeRule), cfg_IniName);
cfg_routCnt = GetPrivateProfileInt("OUTBOUNDROUT", "ROUTCNT", 1, cfg_IniName);
if (cfg_routCnt > 0)
{
outRout = new OutBoundRout[cfg_routCnt+1];
memset(outRout, 0, sizeof(OutBoundRout) * (cfg_routCnt+1));
if (outRout != NULL)
{
char routStr[10] = {0};
char outRoutStr[512] = {0};
for (i = 1; i <= cfg_routCnt; i++)
{
sprintf(routStr, "ROUT[%d]", i);
GetPrivateProfileString("OUTBOUNDROUT", routStr ,"",outRoutStr,sizeof(OutBoundRout),cfg_IniName);
assignmentOutBoundRout(outRoutStr, &outRout[i]);
}
}
}
cfg_FaxMode = GetPrivateProfileInt("FAXMODE", "FaxMode", 0, cfg_IniName);
CreateDailRule(&pDailRuleHead);
return ;
}
示例4: init
int init(int argc, char *argv[]) {
#if WIN32
char currentDirectory[MAX_PATH];
#endif
srand(time(0));
conInit();
loadDefaults();
timerInit();
if (!commandLineRead(argc, argv))
return 0;
if (view.quit)
return 0;
if (!state.dontExecuteDefaultScript)
configRead(findFile(CONFIG_FILE), 0);
#ifndef NO_GUI
if (!gfxInit())
return 1;
#endif
if (state.historyFrames % 2)
state.historyFrames--;
fpsInit();
#ifdef WIN32
// if we've gone this far, lets set the registry key even if it exists...
GetCurrentDirectory(MAX_PATH, currentDirectory);
setRegistryString(REGISTRY_NAME_PATH, currentDirectory);
#endif
#ifdef _OPENMP
conAdd(LHELP, "multi-threaded rendering: max threads = %d. Found %d processors.",
state.processFrameThreads, omp_get_num_procs());
#endif
#ifndef NO_STDIO_REDIRECT
// say hi (and keep stdout.txt alive on windows...)
if(!view.useStdout && !view.screenSaver)
printf("Welcome to %s.\n", GRAVIT_VERSION);
#endif
#ifdef WITHOUT_AGAR
conAdd(LHELP, "Welcome to Gravit!");
#ifndef NO_GUI
conAdd(LHELP, "Quick Start: Hit SPACE to start a new simulation!");
conAdd(LHELP, "Hold down a mouse button and move it around. Use A and Z keys, or the scroll wheel to zoom in and out.");
#endif
#endif
return 0;
}
示例5: VSRM_GetPath
int VSRM_GetPath(char *filepath, unsigned int size)
{
#ifdef _WIN32
int nSize = 0, i=0;
char szPath[MAX_PATH] = {0,};
GetModuleFileName(NULL, szPath, sizeof(szPath));
nSize = (int)strlen(szPath);
i=nSize;
for (i=nSize; i>0; i--)
{
if (szPath[i]=='\\')
{
szPath[i] = '\0';
break;
}
szPath[i] = '\0';
}
if (i < 1)
{
GetCurrentDirectory(MAX_PATH, szPath);
nSize = (int)strlen(szPath);
if ((unsigned int)nSize > size)
{
printf("VSRM_GetPath:: 傳入路徑長度太小. 無法複製當前路徑.");
}
else
{
strncpy(filepath, szPath, nSize);
}
}
else
{
strncpy(filepath, szPath, nSize);
}
return 0;
#else
char path[260] = {0,};
int cnt = readlink("/proc/self/exe", path, sizeof(path));
if (cnt < 0 || cnt>=sizeof(path))
{
printf("readlink error..\n");
return -1;
}
int i=0;
for (i=cnt; i>=0; --i)
{
if (path[i] == '/')
{
path[i+1] = '\0';
break;
}
}
int nSize = (int)strlen(path);
if ((unsigned int)nSize > size)
{
_TRACE_ERR("VSRM_GetPath:: 傳入路徑長度太小. 無法複製當前路徑.");
}
else
{
strncpy(filepath, path, nSize);
return 0;
}
return -1;
#endif
}
示例6: while
//.........這裏部分代碼省略.........
nParentPID = mn_InsideParentPID;
}
else
{
PROCESSENTRY32 pi = {sizeof(pi)};
if (!GetProcessInfo(GetCurrentProcessId(), &pi) || !pi.th32ParentProcessID)
{
DisplayLastError(L"GetProcessInfo(GetCurrentProcessId()) failed");
m_InsideIntegration = ii_None;
mh_InsideParentWND = NULL;
goto wrap;
}
nParentPID = pi.th32ParentProcessID;
}
EnumWindows(EnumInsideFindParent, nParentPID);
if (!mh_InsideParentRoot)
{
int nBtn = MsgBox(L"Can't find appropriate parent window!\n\nContinue in normal mode?", MB_ICONSTOP|MB_YESNO|MB_DEFBUTTON2);
if (nBtn != IDYES)
{
mh_InsideParentWND = INSIDE_PARENT_NOT_FOUND;
return mh_InsideParentWND; // Закрыться!
}
// Продолжить в обычном режиме
m_InsideIntegration = ii_None;
mh_InsideParentWND = NULL;
goto wrap;
}
HWND hExistConEmu;
if ((hExistConEmu = InsideFindConEmu(mh_InsideParentRoot)) != NULL)
{
_ASSERTE(FALSE && "Continue to create tab in existing instance");
// Если в проводнике уже есть ConEmu - открыть в нем новую вкладку
gpSetCls->SingleInstanceShowHide = sih_None;
LPCWSTR pszCmdLine = GetCommandLine();
LPCWSTR pszCmd = StrStrI(pszCmdLine, L" /cmd ");
gpConEmu->RunSingleInstance(hExistConEmu, pszCmd ? (pszCmd + 6) : NULL);
mh_InsideParentWND = INSIDE_PARENT_NOT_FOUND;
return mh_InsideParentWND; // Закрыться!
}
// Теперь нужно найти дочерние окна
// 1. в которое будем внедряться
// 2. по которому будем позиционироваться
// 3. для синхронизации текущего пути
InsideFindShellView(mh_InsideParentRoot);
RepeatCheck:
if (!mh_InsideParentWND || (!mh_InsideParentRel && (m_InsideIntegration == ii_Explorer)))
{
wchar_t szAddMsg[128] = L"", szMsg[1024];
if (bFirstStep)
{
bFirstStep = false;
if (TurnExplorerTipPane(szAddMsg))
{
goto RepeatCheck;
}
}
//MessageBox(L"Can't find appropriate shell window!", MB_ICONSTOP);
_wsprintf(szMsg, SKIPLEN(countof(szMsg)) L"%sCan't find appropriate shell window!\nUnrecognized layout of the Explorer.\n\nContinue in normal mode?", szAddMsg);
int nBtn = MsgBox(szMsg, MB_ICONSTOP|MB_YESNO|MB_DEFBUTTON2);
if (nBtn != IDYES)
{
mh_InsideParentWND = INSIDE_PARENT_NOT_FOUND;
return mh_InsideParentWND; // Закрыться!
}
m_InsideIntegration = ii_None;
mh_InsideParentRoot = NULL;
mh_InsideParentWND = NULL;
goto wrap;
}
wrap:
if (!mh_InsideParentWND)
{
m_InsideIntegration = ii_None;
mh_InsideParentRoot = NULL;
}
else
{
GetWindowThreadProcessId(mh_InsideParentWND, &mn_InsideParentPID);
// Для мониторинга папки
GetCurrentDirectory(countof(ms_InsideParentPath), ms_InsideParentPath);
int nLen = lstrlen(ms_InsideParentPath);
if ((nLen > 3) && (ms_InsideParentPath[nLen-1] == L'\\'))
{
ms_InsideParentPath[nLen-1] = 0;
}
}
return mh_InsideParentWND;
}
示例7: SetupDriverName
BOOLEAN
SetupDriverName(
_Inout_updates_bytes_all_(BufferLength) PCHAR DriverLocation,
_In_ ULONG BufferLength
)
{
HANDLE fileHandle;
DWORD driverLocLen = 0;
//
// Get the current directory.
//
driverLocLen = GetCurrentDirectory(BufferLength,
DriverLocation
);
if (driverLocLen == 0 || driverLocLen < BufferLength) {
printf("GetCurrentDirectory failed! Error = %d \n", (int)GetLastError());
return FALSE;
}
DriverLocation[ driverLocLen - 1 ] = '\0';
//
// Setup path name to driver file.
//
if (FAILED( StringCbCat(DriverLocation, BufferLength, "\\"DRIVER_NAME".sys") )) {
示例8: getCurrentDirectory
void getCurrentDirectory(char* buffer, int buffer_size)
{
GetCurrentDirectory(buffer_size, buffer);
}
示例9: assert
HRESULT AnimaApplication::CreateInstance( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
assert( AnimaApplication::mInstance == 0 );
HWND hWnd;
WNDCLASSEX winClass;
memset( &winClass, 0x0, sizeof(WNDCLASSEX) );
winClass.lpszClassName = "MY_WINDOWS_CLASS";
winClass.cbSize = sizeof(WNDCLASSEX);
winClass.style = CS_HREDRAW | CS_VREDRAW;
winClass.lpfnWndProc = WindowProc;
winClass.hInstance = hInstance;
winClass.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_DIRECTX_ICON);
winClass.hIconSm = LoadIcon(hInstance, (LPCTSTR)IDI_DIRECTX_ICON);
winClass.hCursor = LoadCursor(NULL, IDC_ARROW);
winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winClass.lpszMenuName = NULL;
winClass.cbClsExtra = 0;
winClass.cbWndExtra = 0;
if( !RegisterClassEx(&winClass) )
return E_FAIL;
hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS",
"DX9 Skinning Sample",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, NULL, NULL, hInstance, NULL );
if( hWnd == NULL )
return E_FAIL;
// register raw input device
RAWINPUTDEVICE Rid[2];
Rid[0].usUsagePage = HID_USAGE_PAGE_GENERIC;
Rid[0].usUsage = HID_USAGE_GENERIC_MOUSE;
Rid[0].dwFlags = RIDEV_INPUTSINK;
Rid[0].hwndTarget = hWnd;
// Keyboard
Rid[1].usUsagePage = HID_USAGE_PAGE_GENERIC;
Rid[1].usUsage = 6;
Rid[1].dwFlags = 0;
Rid[1].hwndTarget=hWnd;
RegisterRawInputDevices( Rid, 2, sizeof(Rid[0]) );
ShowWindow( hWnd, nCmdShow );
UpdateWindow( hWnd );
LPWSTR *szArglist;
int nArgs;
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
TestEnvironment* testEnvironment = new TestEnvironment( nArgs, szArglist );
Math::Random::Init( testEnvironment->GetRandomSeed() );
AnimaApplication::mInstance = new AnimaApplication( winClass, hWnd );
char szCurrentDir[2048];
GetCurrentDirectory( sizeof(szCurrentDir), szCurrentDir );
strcat_s(szCurrentDir, "/../Shaders");
Instance()->mShadersWatcher = FindFirstChangeNotification( szCurrentDir, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
if (Instance()->mShadersWatcher == INVALID_HANDLE_VALUE)
DXTRACE_ERR("Unable to monitor shaders directory. Live shaders editing will not work", E_FAIL );
Instance()->mTestEnvironment = testEnvironment;
Instance()->mRenderContext = new RenderContext( hWnd, DISPLAY_WIDTH, DISPLAY_HEIGHT );
Instance()->mFramerateCounter = new FramerateCounter;
Instance()->mUserInterface = new UserInterface( mInstance->mRenderContext, mInstance->mFramerateCounter );
Instance()->mUserInterface->AcquireResources( Instance()->mRenderContext );
Instance()->mInput = new Input();
Instance()->mCamera = new Camera( *Instance()->mInput, *Instance()->mRenderContext );
// set up renderer
Instance()->mModel = new SkeletalModel( "..\\Models\\frank.dae" );
Instance()->mModel->Load( Instance()->mRenderContext );
Instance()->mModel->SetNext( Instance()->mUserInterface );
Instance()->mModel->PlayAnimation( 0, 0.25f );
Instance()->mModelRotationAngle = 0.f;
Instance()->mRotateModel = true;
Instance()->mFrameCounter = 0;
return S_OK;
}
示例10: GetCurrentDirectory
BOOL CTortoiseGitBlameApp::InitInstance()
{
{
DWORD len = GetCurrentDirectory(0, NULL);
if (len)
{
std::unique_ptr<TCHAR[]> originalCurrentDirectory(new TCHAR[len]);
if (GetCurrentDirectory(len, originalCurrentDirectory.get()))
{
sOrigCWD = originalCurrentDirectory.get();
sOrigCWD = CPathUtils::GetLongPathname(sOrigCWD);
}
}
}
//set the resource dll for the required language
CRegDWORD loc = CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033);
long langId = loc;
CString langDll;
HINSTANCE hInst = NULL;
do
{
langDll.Format(_T("%sLanguages\\TortoiseGitBlame%ld.dll"), (LPCTSTR)CPathUtils::GetAppParentDirectory(), langId);
hInst = LoadLibrary(langDll);
CString sVer = _T(STRPRODUCTVER);
CString sFileVer = CPathUtils::GetVersionFromFile(langDll);
if (sFileVer.Compare(sVer)!=0)
{
FreeLibrary(hInst);
hInst = NULL;
}
if (hInst != NULL)
AfxSetResourceHandle(hInst);
else
{
DWORD lid = SUBLANGID(langId);
lid--;
if (lid > 0)
{
langId = MAKELANGID(PRIMARYLANGID(langId), lid);
}
else
langId = 0;
}
} while ((hInst == NULL) && (langId != 0));
TCHAR buf[6] = { 0 };
_tcscpy_s(buf, _T("en"));
langId = loc;
CString sHelppath;
sHelppath = this->m_pszHelpFilePath;
sHelppath = sHelppath.MakeLower();
sHelppath.Replace(_T(".chm"), _T("_en.chm"));
free((void*)m_pszHelpFilePath);
m_pszHelpFilePath=_tcsdup(sHelppath);
sHelppath = CPathUtils::GetAppParentDirectory() + _T("Languages\\TortoiseGitBlame_en.chm");
do
{
GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO639LANGNAME, buf, _countof(buf));
CString sLang = _T("_");
sLang += buf;
sHelppath.Replace(_T("_en"), sLang);
if (PathFileExists(sHelppath))
{
free((void*)m_pszHelpFilePath);
m_pszHelpFilePath=_tcsdup(sHelppath);
break;
}
sHelppath.Replace(sLang, _T("_en"));
GetLocaleInfo(MAKELCID(langId, SORT_DEFAULT), LOCALE_SISO3166CTRYNAME, buf, _countof(buf));
sLang += _T("_");
sLang += buf;
sHelppath.Replace(_T("_en"), sLang);
if (PathFileExists(sHelppath))
{
free((void*)m_pszHelpFilePath);
m_pszHelpFilePath=_tcsdup(sHelppath);
break;
}
sHelppath.Replace(sLang, _T("_en"));
DWORD lid = SUBLANGID(langId);
lid--;
if (lid > 0)
{
langId = MAKELANGID(PRIMARYLANGID(langId), lid);
}
else
langId = 0;
} while (langId);
setlocale(LC_ALL, "");
// We need to explicitly set the thread locale to the system default one to avoid possible problems with saving files in its original codepage
// The problems occures when the language of OS differs from the regional settings
// See the details here: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100887
SetThreadLocale(LOCALE_SYSTEM_DEFAULT);
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
//.........這裏部分代碼省略.........
示例11: Choose_Prediction
// Open function modified by Donald Graft as part of fix for dropped frames and random frame access.
int CMPEG2Decoder::Open(const char *path)
{
char buf[2048], *buf_p;
Choose_Prediction(this->fastMC);
char ID[80], PASS[80] = "DGIndexProjectFile16";
DWORD i, j, size, code, type, tff, rff, film, ntsc, gop, top, bottom, mapping;
int repeat_on, repeat_off, repeat_init;
int vob_id, cell_id;
__int64 position;
int HadI;
CMPEG2Decoder* out = this;
out->VF_File = fopen(path, "r");
if (fgets(ID, 79, out->VF_File)==NULL)
return 1;
if (strstr(ID, "DGIndexProjectFile") == NULL)
return 5;
if (strncmp(ID, PASS, 20))
return 2;
fscanf(out->VF_File, "%d\n", &File_Limit);
i = File_Limit;
while (i)
{
Infilename[File_Limit-i] = (char*)aligned_malloc(_MAX_PATH, 16);
fgets(Infilename[File_Limit-i], _MAX_PATH - 1, out->VF_File);
// Strip newline.
Infilename[File_Limit-i][strlen(Infilename[File_Limit-i])-1] = 0;
if (PathIsRelative(Infilename[File_Limit-i]))
{
char *p, d2v_stem[_MAX_PATH], open_path[_MAX_PATH];
if (PathIsRelative(path))
{
GetCurrentDirectory(_MAX_PATH, d2v_stem);
if (*(d2v_stem + strlen(d2v_stem) - 1) != '\\')
strcat(d2v_stem, "\\");
strcat(d2v_stem, path);
}
else
{
strcpy(d2v_stem, path);
}
p = d2v_stem + strlen(d2v_stem);
while (*p != '\\' && p != d2v_stem) p--;
if (p != d2v_stem)
{
p[1] = 0;
strcat(d2v_stem, Infilename[File_Limit-i]);
PathCanonicalize(open_path, d2v_stem);
if ((Infile[File_Limit-i] = _open(open_path, _O_RDONLY | _O_BINARY))==-1)
return 3;
}
else
{
// This should never happen because the code should guarantee that d2v_stem has a '\' character.
return 3;
}
}
else
{
if ((Infile[File_Limit-i] = _open(Infilename[File_Limit-i], _O_RDONLY | _O_BINARY))==-1)
return 3;
}
i--;
}
fscanf(out->VF_File, "\nStream_Type=%d\n", &SystemStream_Flag);
if (SystemStream_Flag == 2)
{
fscanf(out->VF_File, "MPEG2_Transport_PID=%x,%x,%x\n",
&MPEG2_Transport_VideoPID, &MPEG2_Transport_AudioPID, &MPEG2_Transport_PCRPID);
fscanf(out->VF_File, "Transport_Packet_Size=%d\n", &TransportPacketSize);
}
fscanf(out->VF_File, "MPEG_Type=%d\n", &mpeg_type);
fscanf(out->VF_File, "iDCT_Algorithm=%d\n", &IDCT_Flag);
switch (IDCT_Flag)
{
case IDCT_MMX:
idctFunc = MMX_IDCT;
break;
case IDCT_SSEMMX:
idctFunc = SSEMMX_IDCT;
if (!cpu.ssemmx)
{
IDCT_Flag = IDCT_MMX;
idctFunc = MMX_IDCT;
}
break;
case IDCT_FPU:
if (!fpuinit)
{
Initialize_FPU_IDCT();
//.........這裏部分代碼省略.........
示例12: GetCurrentDirectory
/*
ANT_DIRECTORY_ITERATOR_RECURSIVE::FIRST()
-----------------------------------------
*/
ANT_directory_iterator_object *ANT_directory_iterator_recursive::first(ANT_directory_iterator_object *object)
{
file_list = handle_stack;
#ifdef _MSC_VER
file_list->first_time = TRUE;
GetCurrentDirectory(sizeof(file_list->path), file_list->path);
strcat(file_list->path, "/*.*");
return next(object);
#else
/* the modification below would not affected the original way of reading files */
long last_slash_idx = strlen(wildcard) - 1;
char *last_char = wildcard + last_slash_idx; // searching backward
char *slash = last_char;
char *got;
if (ANT_disk::is_directory(wildcard))
{
strcpy(path_buffer, wildcard);
strcpy(this->wildcard, "*");
}
else
{
while (slash != wildcard)
{
if(*slash == '/')
break;
slash--;
last_slash_idx--;
}
if (last_slash_idx <= 0) // the wildcard will be wildcard itself
{
if (getcwd(path_buffer, sizeof(path_buffer)) == NULL)
return NULL;
sprintf(path_buffer, "%s/", path_buffer); /* As we will later use this to mark dirs */
}
else // the wildcard will be after slash
{
strncpy(path_buffer, wildcard, last_slash_idx + 1);
path_buffer[last_slash_idx+1] = '\0';
if (last_char == slash)
strcpy(this->wildcard, "*");
else
{
char *wildcard_start = slash;
wildcard_start++;
long wildcard_len = last_char - wildcard_start + 1;
// trim the wildcard path string to contain only the wildcard characters
strncpy(this->wildcard, wildcard_start, wildcard_len);
this->wildcard[wildcard_len] = '\0';
}
}
}
if ((got = first_match_wildcard(path_buffer)) == NULL)
return NULL;
object->filename = strnew(got);
if (get_file)
object->file = ANT_disk::read_entire_file(object->filename, &object->length);
else
{
object->file = NULL;
object->length = 0;
}
return object;
#endif
}
示例13: GetWorkingFolder
std::string GetWorkingFolder()
{
char sCurrentPath[MAX_PATH]={0};
GetCurrentDirectory(MAX_PATH,sCurrentPath);
return sCurrentPath;
}
示例14: GetCurrentDirectory
char *WDL_ChooseFileForOpen2(HWND parent,
const char *text,
const char *initialdir,
const char *initialfile,
const char *extlist,
const char *defext,
bool preservecwd,
int allowmul,
const char *dlgid,
void *dlgProc,
#ifdef _WIN32
HINSTANCE hInstance
#else
struct SWELL_DialogResourceIndex *reshead
#endif
)
{
char olddir[2048];
GetCurrentDirectory(sizeof(olddir),olddir);
#ifdef _WIN32
#ifdef WDL_FILEBROWSE_WIN7VISTAMODE
if (allowmul!=1)
{
Win7FileDialog fd(text);
if(fd.inited())
{
//vista+ file open dialog
fd.addOptions(FOS_FILEMUSTEXIST|(allowmul?FOS_ALLOWMULTISELECT:0));
fd.setFilterList(extlist);
if (defext)
{
fd.setDefaultExtension(defext);
int i = 0;
const char *p = extlist;
while(*p)
{
if(*p) p+=strlen(p)+1;
if(!*p) break;
if(stristr(p, defext))
{
fd.setFileTypeIndex(i+1);
break;
}
i++;
p+=strlen(p)+1;
}
}
fd.setFolder(initialdir?initialdir:olddir, 0);
fd.setTemplate(hInstance, dlgid, (LPOFNHOOKPROC)dlgProc);
if(initialfile)
{
char temp[4096];
lstrcpyn_safe(temp,initialfile,sizeof(temp));
//check for folder name
if (WDL_remove_filepart(temp))
{
//folder found
fd.setFolder(temp, 0);
fd.setFilename(temp + strlen(temp) + 1);
}
else
fd.setFilename(temp);
}
if(fd.show(parent))
{
char *ret=NULL;
char temp[4096];
temp[0]=0;
//ifileopendialog saves the last folder automatically
if (!allowmul)
{
fd.getResult(temp, sizeof(temp)-1);
ret= temp[0] ? strdup(temp) : NULL;
}
else
{
char* p=NULL;
int totallen=0, cnt=fd.getResultCount();
if (cnt>1)
{
// sets an empty path as 1st returned string for multipath support
// (when selecting files among search results for ex.)
ret = strdup("");
totallen=1;
}
int i;
for (i=0; i<cnt; i++)
{
int len = fd.getResult(i, temp, sizeof(temp)-1);
p = len ? (char*)realloc(ret, totallen + len + ((i==cnt-1)?1:0)) : NULL;
if (p)
{
//.........這裏部分代碼省略.........
示例15: InitInstance
virtual BOOL InitInstance()
{
try{
SetRegistryKey(G_softwarename());
//boost process priority
SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS);
AfxInitRichEdit();
// AfxEnableControlContainer();
// AfxOleInit();
{//create documents folder
QString dir;
GetDocumentsDir(dir);dir+=_qstr("\\");dir+=G_softwarename();
CreateDirectory(dir,NULL);
}
CWinApp::InitInstance();
//for 3D Connexion
if (!AfxOleInit())
{
AfxMessageBox(L"OLE Init failed");
return FALSE;
}
AfxEnableControlContainer();
StrChar locstartupdir[600];
GetCurrentDirectory(599,locstartupdir);
startupdir=locstartupdir;
datadir=startupdir+_qstr("/Data");
{
QString storeddatadir;
QParamRead(PARAMLOCATION_REGISTRY,_qstr("DataDirectory"),storeddatadir);
if (qstrlen(storeddatadir)>0)
datadir=storeddatadir;
}
initlog();
addlog(TFormatString(_text("Data directory: ^1"),datadir));
scriptsdir=datadir;scriptsdir+=_qstr("\\Scripts");
texturesdir=datadir;texturesdir+=_qstr("\\textures");
addlog(_text("Fetching MAC address"));
GetMACaddress(MACaddr);
addlog(MACaddr);
G_3DCosmos().LoadSettings();
G_3DCosmos().init();
loadstockcyclorbits();
G_QXSys().startup();
addlog(_text("Loading languages"),+1);
QTranslate::Get().loadlanguages();
addlog(_text("Loaded languages"),-1);
addlog(_text("Creating source code window"),+1);
mainwin= new Tmainwin();
mainwin->createwindow(NULL,QString("Source code window"));
addlog(_text("Source code window created"),-1);
addlog(_text(""));
addlog(_text(""));
mainwin->ShowWindow(m_nCmdShow);
m_pMainWnd=mainwin;
}
catch(QError &err)
{
reporterror(err.G_content());
}
return TRUE;
}