Ignore:
Timestamp:
Apr 8, 2015, 4:06:48 AM (8 years ago)
Author:
roman
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/Miscellaneous/GetModuleFileName01/Launch/Launch.cpp

    r391 r392  
    11#include "stdafx.h"
     2#include <shlwapi.h>
    23
    34int _tmain(int argc, _TCHAR* argv[])
    45{
    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);
    619        STARTUPINFO StartupInfo;
    720        ZeroMemory(&StartupInfo, sizeof StartupInfo);
    821        StartupInfo.cb = sizeof StartupInfo;
    922        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);
    1124        if(!bResult)
    1225        {
    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;
    1430                TCHAR pszShortPath[MAX_PATH] = { 0 };
    15                 ATLVERIFY(GetShortPathName(g_pszPath, pszShortPath, _countof(pszShortPath)));
     31                ATLVERIFY(GetShortPathName(pszPath, pszShortPath, _countof(pszShortPath)));
    1632                _tprintf(_T("Short Path: (%d) %s\n"), _tcslen(pszShortPath), pszShortPath);
    1733                bResult = CreateProcess(pszShortPath, NULL, NULL, NULL, TRUE, 0, NULL, NULL, &StartupInfo, &ProcessInformation);
     
    2440
    2541/*
     42
     43Win32:
     44
     45Path: (279) \\?\D:\Projects\Alax.Info\Repository-Public\Utilities\Miscellaneous\GetModuleFileName01\_Bin\Win32\Debug\123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\GetModuleFileName01.exe
    2646Error: 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
     47Short 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
     51x64:
     52
     53Path: (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
    3057*/
Note: See TracChangeset for help on using the changeset viewer.