#include #include #include #include #pragma comment(lib, "ktmw32") int main(int argc, char** argv) { LSTATUS st; // // Create a transaction. // HANDLE hTrans = CreateTransaction(NULL, NULL, 0, 0, 0, 0, NULL); if (hTrans == INVALID_HANDLE_VALUE) { printf("CreateTransaction failed with error %u\n", GetLastError()); return 1; } // // Create a test key in HKCU within the transaction. // HKEY hTestKey; st = RegCreateKeyTransactedA(HKEY_CURRENT_USER, "Test", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hTestKey, NULL, hTrans, NULL); if (st != ERROR_SUCCESS) { printf("RegCreateKeyTransactedA failed with error %d\n", st); return 1; } // // Set a new value in the transactionally created key. // st = RegSetValueExA(hTestKey, "Value", 0, REG_BINARY, (const BYTE*)"AAAA", 4); if (st != ERROR_SUCCESS) { printf("RegSetValueExA failed with error %d\n", st); return 1; } // // Commit the transaction. // if (!CommitTransaction(hTrans)) { printf("CommitTransaction failed with error %u\n", GetLastError()); return 1; } RegCloseKey(hTestKey); CloseHandle(hTrans); return 0; }