Board index » cppbuilder » Database not saved when Windows shuts down
Joseph F. Muscarell
![]() CBuilder Developer |
Tue, 28 Sep 2004 21:39:23 GMT
Database not saved when Windows shuts down
I am developing an embedded application for Windows 2000 Pro that allows the
user to shut down the computer/system from the GUI. My problem is that any changes made to my TDatabase are not saved when windows shuts down. If the program only is closed in the normal way, the database changes are intact upon the next execution. Here is the code I am using to shut down Windows: // The following code is from Microsoft MSDN Library online. HANDLE hToken; // Get a token for this process. if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | // Get the LUID for the shutdown privilege. LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set // Get the shutdown privilege for this process. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); // Cannot test the return value of AdjustTokenPrivileges. if (GetLastError() != ERROR_SUCCESS) // Shut down the system and force all applications to close. if (!ExitWindowsEx(EWX_SHUTDOWN, 0)) When Windows is shutdown is my program terminated in some way that is not Is there any way to force the Database to save itself before this shutdown? All help will be greatly appreciated. Joseph F. Muscarella |