GetOwnerInfo

Up
CommonControls
CreateFont
Database
CEDIB
CEFonts
CEGDI
GetOwnerInfo
CESystem
ScreenCapture
CEWindows
ListBoxChildren
Directory Tree
OwnerDrawButtons
CECalenderControl
Imgdecmp
Inking
PropertySheets
CommandLine
VirtualListView
SetOwnerInfo
SystemParameterInfo

Home
Up

 

Name: CEGetOwnerInfo

Download: CEGetOwnerInfo.zip

What is it: Demostrates how to get the Owner information out of the registry.

 

Features:

  1. This sample provides you with code (in the CEOwnerInfo.h file) to get and set Owner information
  2. The included file also will get and set the Notes information

The Code:

// Owner information is found in the HKEY_CURRENT_USER\\Control Panel\\Owner
// Keys Owner and Notes
// Owner info is fixedlength Unicode in a large binary datatype
 

It is important to note that these are the fixed field lengths in the Owner Info control panel. Therefore the actual values you would use if setting up an array of TCHAR's is the named value plus 1 for the NULL character.

// Name: 32 TCHAR
// Company: 32 TCHAR
// Address: 128 TCHAR
// Work Phone: 24 TCHAR
// Home Phone: 24 TCHAR
// These lengths include space for the NULL
#define OWNERNAMELENGTH 33 //TCHAR + NULL
#define COMPANYLENGTH 33
#define ADDRESSLENGTH 129
#define WORKPHONELENGTH 25
#define HOMEPHONELENGTH 25
 

So this is the definition of the struct which is used by the Owner Info functions.

typedef struct {
UINT cbSize;
TCHAR OwnerName[OWNERNAMELENGTH]; //32 + NULL
TCHAR Company[COMPANYLENGTH]; //32 + NULL
TCHAR Address[ADDRESSLENGTH]; //128 + NULL
WORD Reserved1[16]; //16
TCHAR WorkPhone[WORKPHONELENGTH]; //24 + NULL
WORD Reserved2[16]; //16
TCHAR HomePhone[HOMEPHONELENGTH]; //24 + NULL
WORD Reserved3; // 2
} CEOWNERINFO, *LPCEOWNERINFO;
 

And this is the definition of the struct which is used by the Notes Info functions.

// These lengths include space for the NULL
#define NOTELENGTH 120 //TCHAR + NULL
typedef struct {
UINT cbSize;
TCHAR Note[NOTELENGTH]; //119 + NULL
WORD Reserved1[74]; //16
} CEOWNERNOTEINFO, *LPCEOWNERNOTEINFO;
 

These are the functions defined in this include file.

BOOL GetCEOwnerInfo(CEOWNERINFO* poinfo);
BOOL SetCEOwnerInfo(CEOWNERINFO* poinfo);
//
BOOL GetCEOwnerNoteInfo(CEOWNERNOTEINFO* poninfo);
BOOL SetCEOwnerNoteInfo(CEOWNERNOTEINFO* poninfo);
//
BOOL GetCEOwnerInfo(CEOWNERINFO* poinfo){

This is the key which contains the Owner and Notes Info. Key/Value pairs.

retCode = RegOpenKeyEx (HKEY_CURRENT_USER,
TEXT("ControlPanel\\Owner"),
0,
KEY_READ,
&hKey);
 

This is the key which contains the Owner Info.

retCode = RegQueryValueEx( hKey, // handle of key to query
TEXT("Owner"),
NULL,
&dwType,
(LPBYTE)poinfo->OwnerName,
&cbData);

This is the setting the Owner Information after insuring that the last byte in the strings is set to NULL.

BOOL SetCEOwnerInfo(CEOWNERINFO* poinfo){
// Set "Owner" data
poinfo->OwnerName[OWNERNAMELENGTH - 1] = '\0'; //Insure it is NULL terminated
poinfo->Company[COMPANYLENGTH - 1] = '\0'; //Insure it is NULL terminated
poinfo->Address[ADDRESSLENGTH - 1] = '\0'; //Insure it is NULL terminated
poinfo->WorkPhone[WORKPHONELENGTH - 1] = '\0'; //Insure it is NULL terminated
poinfo->HomePhone[HOMEPHONELENGTH - 1] = '\0'; //Insure it is NULL terminated
retCode = RegSetValueEx(
hKey, // handle of key to set value for
TEXT("Owner"),
NULL, // reserved
dwType,
(LPBYTE)poinfo->OwnerName,
cbData);
 

This page was last updated on 06/03/99.

 Feedback mailto:ppcdev@conduits.com