我在這裏基本上試圖實現的是恢復髒數據庫的正確方法。如何使用微軟的API恢復/恢復ESE數據庫
esentutl /mh db.dat
產生以下輸出
這是很好的,因爲我把數據庫的副本,而由另一程序中打開。
是否可以使用微軟的JetBlue Api打開數據庫而沒有正確的日誌& chk文件? (ESEDatabaseView確實不知何故,nirsoft.net)
如果這樣的情況下,是不可能與微軟的API,以及需要記錄,什麼是恢復數據庫的正確方法(我改變了DB的&日誌的位置)
這裏是我的代碼:
wpath p2 = L"C:\\m.db";
ULONG unPageSize;
long jet_err = JetGetDatabaseFileInfoW(p2.file_string().c_str(), &unPageSize, sizeof(unPageSize), JET_DbInfoPageSize);
if (jet_err != JET_errSuccess) {
return false;
}
jet_err = JetSetSystemParameter(NULL, NULL, JET_paramDatabasePageSize, unPageSize, NULL);
if (jet_err != JET_errSuccess) {
return false;
}
jet_err = JetSetSystemParameter(NULL, NULL, JET_paramRecovery, 0, "Off");
if (jet_err != JET_errSuccess) {
return false;
}
jet_err = JetSetSystemParameter(NULL, NULL, JET_paramLogFilePath, 0, "C:\\");
if (jet_err != JET_errSuccess) {
return false;
}
jet_err = JetSetSystemParameter(NULL, NULL, JET_paramSystemPath, 0, "C:\\");
if (jet_err != JET_errSuccess) {
return false;
}
jet_err = JetSetSystemParameter(NULL, NULL, JET_paramAlternateDatabaseRecoveryPath, 0, "C:\\");
if (jet_err != JET_errSuccess) {
return false;
}
JET_INSTANCE instance = { 0 };
jet_err = JetCreateInstance(&instance, "instance");
if (jet_err != JET_errSuccess) {
return false;
}
jet_err = JetInit(&instance);
if (jet_err != JET_errSuccess) {
JetTerm(instance);
return false;
}
JET_SESID sesid;
jet_err = JetBeginSession(instance, &sesid, 0, 0);
if (jet_err != JET_errSuccess) {
JetTerm(instance);
return false;
}
jet_err = JetAttachDatabaseW(sesid, pathESEDbLocation.file_string().c_str(), JET_bitDbReadOnly);
if (jet_err != JET_errSuccess) {
JetEndSession(sesid, 0);
JetTerm(instance);
return false;
}
JetAttachDatabaseW
失敗-550 JET_errDatabaseDirtyShutdown
編輯我發現沒有任何檢查點和日誌文件的調用esenutl /p data.dat
也解決了這個問題。我已經使用JetExternalRestoreW
命令嘗試,但它不斷拋出#define JET_errFileNotFound -1811 /* File not found */
JET_RSTMAP_W p = {L"C:/Users/user/AppData/Local/Temp/db/db.dat", L"C:/Users/user/AppData/Local/Temp/db/db.dat"};
jet_err = JetExternalRestoreW(nullptr, L"C:/Users/user/AppData/Local/Temp/db/", &p, 1,L"C:/Users/igalk/AppData/Local/Temp/db/", 0, 0, nullptr);