source: trunk/Utilities/Miscellaneous/GetModuleFileName01/Launch/Launch.cpp @ 391

Last change on this file since 391 was 391, checked in by roman, 8 years ago
File size: 1.5 KB
Line 
1#include "stdafx.h"
2
3int _tmain(int argc, _TCHAR* argv[])
4{
5        static LPCTSTR g_pszPath = _T("\\\\?\\D:\\Projects\\Alax.Info\\Repository-Public\\Utilities\\Miscellaneous\\GetModuleFileName01\\Debug\\123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\\GetModuleFileName01.exe");
6        STARTUPINFO StartupInfo;
7        ZeroMemory(&StartupInfo, sizeof StartupInfo);
8        StartupInfo.cb = sizeof StartupInfo;
9        PROCESS_INFORMATION ProcessInformation;
10        BOOL bResult = CreateProcess(g_pszPath, NULL, NULL, NULL, TRUE, 0, NULL, NULL, &StartupInfo, &ProcessInformation);
11        if(!bResult)
12        {
13                _tprintf(_T("Error: %d\n"), GetLastError()); // 122 = ERROR_INSUFFICIENT_BUFFER
14                TCHAR pszShortPath[MAX_PATH] = { 0 };
15                ATLVERIFY(GetShortPathName(g_pszPath, pszShortPath, _countof(pszShortPath)));
16                _tprintf(_T("Short Path: (%d) %s\n"), _tcslen(pszShortPath), pszShortPath);
17                bResult = CreateProcess(pszShortPath, NULL, NULL, NULL, TRUE, 0, NULL, NULL, &StartupInfo, &ProcessInformation);
18        }
19        ATLASSERT(bResult);
20        ATLVERIFY(CloseHandle(ProcessInformation.hThread));
21        ATLVERIFY(CloseHandle(ProcessInformation.hProcess));
22        return 0;
23}
24
25/*
26Error: 122
27Short 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
30*/
Note: See TracBrowser for help on using the repository browser.