- Timestamp:
- Apr 8, 2015, 4:06:48 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Utilities/Miscellaneous/GetModuleFileName01/Launch/Launch.cpp
r391 r392 1 1 #include "stdafx.h" 2 #include <shlwapi.h> 2 3 3 4 int _tmain(int argc, _TCHAR* argv[]) 4 5 { 5 static LPCTSTR g_pszPath = _T("\\\\?\\D:\\Projects\\Alax.Info\\Repository-Public\\Utilities\\Miscellaneous\\GetModuleFileName01\\Debug\\123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\\GetModuleFileName01.exe"); 6 TCHAR pszPath[1024] = { 0 }; 7 ATLVERIFY(GetModuleFileName(NULL, pszPath + 4, _countof(pszPath) - 4)); 8 ATLVERIFY(PathRemoveFileSpec(pszPath + 4)); 9 pszPath[0] = _T('\\'); 10 pszPath[1] = _T('\\'); 11 pszPath[2] = _T('?'); 12 pszPath[3] = _T('\\'); 13 static const LPCTSTR g_pszSubdirectory = _T("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); 14 _tcscat_s(pszPath, _T("\\")); 15 _tcscat_s(pszPath, g_pszSubdirectory); 16 _tcscat_s(pszPath, _T("\\")); 17 _tcscat_s(pszPath, _T("GetModuleFileName01.exe")); 18 _tprintf(_T("Path: (%d) %s\n"), _tcslen(pszPath), pszPath); 6 19 STARTUPINFO StartupInfo; 7 20 ZeroMemory(&StartupInfo, sizeof StartupInfo); 8 21 StartupInfo.cb = sizeof StartupInfo; 9 22 PROCESS_INFORMATION ProcessInformation; 10 BOOL bResult = CreateProcess( g_pszPath, NULL, NULL, NULL, TRUE, 0, NULL, NULL, &StartupInfo, &ProcessInformation);23 BOOL bResult = CreateProcess(pszPath, NULL, NULL, NULL, TRUE, 0, NULL, NULL, &StartupInfo, &ProcessInformation); 11 24 if(!bResult) 12 25 { 13 _tprintf(_T("Error: %d\n"), GetLastError()); // 122 = ERROR_INSUFFICIENT_BUFFER 26 const DWORD nLastError = GetLastError(); 27 _tprintf(_T("Error: %d\n"), nLastError); 28 if(nLastError != ERROR_INSUFFICIENT_BUFFER) 29 return 1; 14 30 TCHAR pszShortPath[MAX_PATH] = { 0 }; 15 ATLVERIFY(GetShortPathName( g_pszPath, pszShortPath, _countof(pszShortPath)));31 ATLVERIFY(GetShortPathName(pszPath, pszShortPath, _countof(pszShortPath))); 16 32 _tprintf(_T("Short Path: (%d) %s\n"), _tcslen(pszShortPath), pszShortPath); 17 33 bResult = CreateProcess(pszShortPath, NULL, NULL, NULL, TRUE, 0, NULL, NULL, &StartupInfo, &ProcessInformation); … … 24 40 25 41 /* 42 43 Win32: 44 45 Path: (279) \\?\D:\Projects\Alax.Info\Repository-Public\Utilities\Miscellaneous\GetModuleFileName01\_Bin\Win32\Debug\123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\GetModuleFileName01.exe 26 46 Error: 122 27 Short Path: (90) \\?\D:\Projects\ALAX~1.INF\REPOSI~2\UTILIT~1\MISCEL~1\GETMOD~1\Debug\123456~1\GETMOD~1.EXE 28 (90) \\?\D:\Projects\ALAX~1.INF\REPOSI~2\UTILIT~1\MISCEL~1\GETMOD~1\Debug\123456~1\GETMOD~1.EXE 29 (90) \\?\D:\Projects\ALAX~1.INF\REPOSI~2\UTILIT~1\MISCEL~1\GETMOD~1\Debug\123456~1\GETMOD~1.EXE 47 Short Path: (101) \\?\D:\Projects\ALAX~1.INF\REPOSI~2\UTILIT~1\MISCEL~1\GETMOD~1\_Bin\Win32\Debug\123456~1\GETMOD~1.EXE 48 (101) \\?\D:\Projects\ALAX~1.INF\REPOSI~2\UTILIT~1\MISCEL~1\GETMOD~1\_Bin\Win32\Debug\123456~1\GETMOD~1.EXE 49 (101) \\?\D:\Projects\ALAX~1.INF\REPOSI~2\UTILIT~1\MISCEL~1\GETMOD~1\_Bin\Win32\Debug\123456~1\GETMOD~1.EXE 50 51 x64: 52 53 Path: (277) \\?\D:\Projects\Alax.Info\Repository-Public\Utilities\Miscellaneous\GetModuleFileName01\_Bin\x64\Debug\123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\GetModuleFileName01.exe 54 (259) \\?\D:\Projects\Alax.Info\Repository-Public\Utilities\Miscellaneous\GetModuleFileName01\_Bin\x64\Debug\123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\GetMo 55 (277) \\?\D:\Projects\Alax.Info\Repository-Public\Utilities\Miscellaneous\GetModuleFileName01\_Bin\x64\Debug\123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\GetModuleFileName01.exe 56 30 57 */
Note: See TracChangeset
for help on using the changeset viewer.