to unlock the drive g:, for convenience, using a bat file unlock.bat
The bat file content is: manage-bde -unlock g: -rp 326000-202006-900200-039038-535898-009303-683253-581356
This line work manually, after double-click the .bat file under windows 7, the drive g: will be unlocked normally.
for more convenient, attempting to run it automatically through calling the EXE file, using CreateProcess to realize, as follows:
SECURITY_ATTRIBUTES sa;
HANDLE hRead,hWrite;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
if (!CreatePipe(&hRead,&hWrite,&sa,0))
{
return FALSE;
}
STARTUPINFO si;
PROCESS_INFORMATION pi;
si.cb = sizeof(STARTUPINFO);
GetStartupInfo(&si);
si.hStdError = hWrite;
si.hStdOutput = hWrite;
si.wShowWindow = SW_SHOW;
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
if(!CreateProcess(NULL, EXECDOSCMD ,NULL,NULL,TRUE,NULL,NULL,NULL,&si,&pi))
{
AfxMessageBox("false");
return FALSE;
}
CloseHandle(hWrite);
char buffer[4096] = {0};
DWORD bytesRead;
while (true)
{
if (ReadFile(hRead,buffer,4095,&bytesRead,NULL) == NULL)
break;
AfxMessageBox(buffer);
Sleep(200);
}
return TRUE;
The results are
****************************************
C:\>manage-bde.exe -unlock g: -rp
326000-202006-900200-039038-535898-009303-683253-581356
'manage-bde.exe'is not recognized as an internal or external command, operable pregram
Or batch file.
****************************************
If the contents of the bat file to Ping www.139.com
Result
****************************************
Being Ping 163.xdwscache.glb0.lxdns.com [121.14.228.43] has 32 bytes of data:
From 121.14.228.43: =32 =11ms TTL=55 byte time
From 121.14.228.43: =32 =11ms TTL=55 byte time
From 121.14.228.43: =32 =10ms TTL=55 byte time
From 121.14.228.43: =32 =11ms TTL=55 byte time
121.14.228.43 Ping statistics:
Packet: sent = 4, received = 4, loss = 0 (0% lost),
The estimation of round trip time (in milliseconds):
The shortest = 10ms, the longest average = = 11ms, 10ms
****************************************
One might argue that when system boot, it can directly run .bat file, because I want to save the password in a different place, not in .bat file, so I want to use the EXE to solve. There may also be one will say, directly calls the manage-bde.exe will also unlock the drive, but I have tried for a long time, later abandoned. directly calling the .bat file, is a relatively simple approach I think.
Maybe the problem is not a simple VC problem!!
who knows how to use manage-bde that can practise my trying, Thank you.