beautypg.com

Setting up registry with user application, 2 setting up registry with user application – Casio PA-2400W User Manual

Page 52

background image

52

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

#include

#include

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 command-to-response interval timeout

const

DWORD Value

= 1800L;

// Time-out value to be set (seconds)

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)