00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "stdafx.h"
00014
00015
00016
00017
00018
00019 CString GetInstallPath()
00020 {
00021 const char* LPMCamera = "Software\\LPMCamera";
00022 const char* InstallPath = "InstallPath";
00023
00024 static unsigned char *path = NULL;
00025
00026
00027
00028
00029 if ( 0 != path )
00030 {
00031 return path;
00032 }
00033
00034
00035
00036
00037 HKEY regKey;
00038
00039 if ( 0 != RegOpenKey(
00040 HKEY_CURRENT_USER,
00041 LPMCamera,
00042 ®Key
00043 ) )
00044 {
00045 return "[error opening registry key]";
00046 }
00047
00048
00049
00050
00051 DWORD valType;
00052 DWORD valLength;
00053
00054 if ( 0 != RegQueryValueEx(
00055 regKey,
00056 InstallPath,
00057 NULL,
00058 &valType,
00059 NULL,
00060 &valLength
00061 ) )
00062 {
00063 return "[error reading registry value]";
00064 }
00065
00066
00067
00068
00069 if ( 0 == ( path = new unsigned char[ valLength ] ) )
00070 {
00071 return "[memory allocation error]";
00072 }
00073
00074
00075
00076
00077 if ( 0 != RegQueryValueEx(
00078 regKey,
00079 InstallPath,
00080 NULL,
00081 &valType,
00082 (unsigned char*)path,
00083 &valLength
00084 ) )
00085 {
00086 return "[error reading registry value]";
00087 }
00088
00089
00090
00091
00092 if ( 0 != RegCloseKey(
00093 regKey
00094 ) )
00095 {
00096 return "[error closing registry key]";
00097 }
00098
00099 return path;
00100 }
00101
00102
00103
00104
00105