How do I capture the root directory using wimgapi?

heavenlygirl 1 Reputation point
2021-04-29T01:57:17.827+00:00

I want to capture a root directory or a volume.
General directory works but root directory(C:, D:, C:\, D:\, etc..) doesn't in my code.
(exception thrown: read access violation it 0x1.
at __crt_seh_guarded_call of Internal_shared.h )

How can I solve this problem?

here is my code :

WCHAR destPath[MAX_PATH];
     wsprintf(destPath, L"%c:\\Drive.WIM", 'D');

     HANDLE hWim = NULL, hImage = NULL;
     PWSTR pszWimFile = NULL;   // Source .wim file

     DWORD  dwCreateFlags = 0,
     dwCreateResult = 0,
     dwImageIndex = 1,
     dwError = 0;

     hWim = WIMCreateFile(destPath,         
     WIM_GENERIC_WRITE,    
     WIM_CREATE_ALWAYS, 
     dwCreateFlags,
     WIM_COMPRESS_XPRESS,                   
     &dwCreateResult);
     if (!hWim)
     {
     int n = 1;
     }
            WCHAR pszTmpDir[MAX_PATH];
     wsprintf(pszTmpDir, L"%c:\\Temp", 'D');
     bRet = WIMSetTemporaryPath(hWim, pszTmpDir);

     DWORD dwCaptureFlags = 0;
     TCHAR *captureDir = TEXT("E:"); //ROOT Directory
     // TCHAR *captureDir = TEXT("E:\\test"); //It works!
     HANDLE h = WIMCaptureImage(hWim, captureDir, dwCaptureFlags);

Thanks.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,634 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,742 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.