7.9.2 Setting Up Registry with User Application
Modify the registry as required from your application while referencing the following sample program.
/***********************************************/
/* Registry Registration Program*/ /***********************************************/
#include <windows.h> #include <string.h> #include <commctrl.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{
HKEY hKey1; |
| // Open Handle | |
LONG lReg1; |
| // Result code | |
DWORD Disp1; |
| // Create or Open disposition | |
int |
| err; |
|
const | wchar_t | SubKey1[] | = TEXT( "FLCE"); // Key for FLCE |
const | wchar_t | Name[] | = TEXT( "RECVWAIT"); |
|
|
| // Name for the |
const | DWORD Value | = 1800L; | |
|
|
| // |
err=TRUE; |
|
|
// Open the registry key
lReg1=RegCreateKeyEx( HKEY_CURRENT_USER, SubKey1, 0, NULL, 0, 0, 0,
&hKey1, &Disp1);
if( lReg1 == ERROR_SUCCESS) { // Set the value
lReg1=RegSetValueEx( hKey1, Name, 0, REG_DWORD, ( const BYTE *)&Value, sizeof( Value)); if( lReg1 != ERROR_SUCCESS)
err=FALSE;
//Close the registry key. lReg1=RegCloseKey( hKey1); if( lReg1 != ERROR_SUCCESS)
52