PSS ID Number: 195605
Article Last Modified on 10/2/2003
HKEY_LOCAL_MACHINE\Drivers\BuiltInEach built-in driver has a subkey that contains various values that the operating system uses when loading the driver. The "Dll" value is a REG_SZ value, which identifies the file that houses the driver. This file is in use as soon as the operating system is started.
140570 HOWTO: Move Files That Are Currently in Use
#include <windows.h>
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow) {
WCHAR szMsg[255];
if ( DeleteFile( L"\\Windows\\MyDriver.dll" ) ) {
MessageBox( NULL, L"DeleteFile() succeeded.",
L"Information", MB_ICONINFORMATION );
} else {
wsprintf( szMsg, L"DeleteFile() failed. Error %d\n",
GetLastError() );
MessageBox( NULL, szMsg, L"Error", MB_ICONEXCLAMATION );
if ( MoveFile( L"\\Windows\\MyDriver.dll",
L"\\Recycled\\MyDriver.old" ) ) {
MessageBox( NULL, L"MoveFile() succeeded.",
L"Information", MB_ICONINFORMATION );
} else {
wsprintf( szMsg, L"MoveFile() failed. Error %d\n",
GetLastError() );
MessageBox( NULL, szMsg, L"Error", MB_ICONEXCLAMATION );
}
}
return 0;
}
NOTE: When a file that is in use is moved to the Recycle Bin, its name
becomes unreadable. It usually shows up in Windows Explorer as nonsense
characters. If you want to open a file by name after moving it, you should
move it to a temporary directory. Furthermore, any attempt to empty the
Recycle Bin does not successfully remove a file that is in use. Once the
device has been restarted, you can successfully empty the Recycle Bin.
Keywords: kbAPI kbDLL kbhowto KB195605
Technology: kbAudDeveloper kbWin32API kbWin32sSearch