本文整理汇总了C++中RegCreateKeyEx函数的典型用法代码示例。如果您正苦于以下问题:C++ RegCreateKeyEx函数的具体用法?C++ RegCreateKeyEx怎么用?C++ RegCreateKeyEx使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RegCreateKeyEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MessageBox
int MachineInstaller::PerformMachineInstallSetup()
{
wchar_t packageName[512];
if (!findPackageFromEmbeddedZip(packageName, sizeof(packageName))) {
MessageBox(NULL, L"Corrupt installer", L"Cannot find package name for installer, is it created correctly?", MB_OK);
return ERROR_INVALID_PARAMETER;
}
wchar_t machineInstallFolder[MAX_PATH];
SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, machineInstallFolder);
wcscat(machineInstallFolder, L"\\SquirrelMachineInstalls");
// NB: This is the DACL for Program Files
wchar_t sddl[512] = L"D:PAI(A;;FA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)(A;CIIO;GA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)(A;;0x1301bf;;;SY)(A;OICIIO;GA;;;SY)(A;;0x1301bf;;;BA)(A;OICIIO;GA;;;BA)(A;;0x1200a9;;;BU)(A;OICIIO;GXGR;;;BU)(A;OICIIO;GA;;;CO)";
if (IsWindows8OrGreater()) {
// Add ALL APPLICATION PACKAGES account (Only available on Windows 8 and greater)
wcscat(sddl, L"(A;;0x1200a9;;;AC)(A;OICIIO;GXGR;;;AC)");
}
PSECURITY_DESCRIPTOR descriptor;
ConvertStringSecurityDescriptorToSecurityDescriptor(
sddl,
SDDL_REVISION_1,
&descriptor, NULL);
SECURITY_ATTRIBUTES attrs;
attrs.nLength = sizeof(SECURITY_ATTRIBUTES);
attrs.bInheritHandle = false;
attrs.lpSecurityDescriptor = descriptor;
if (!CreateDirectory(machineInstallFolder, &attrs) && GetLastError() != ERROR_ALREADY_EXISTS) {
LocalFree(descriptor);
return GetLastError();
}
LocalFree(descriptor);
wcscat(machineInstallFolder, L"\\");
wcscat(machineInstallFolder, packageName);
wcscat(machineInstallFolder, L".exe");
wchar_t ourFile[MAX_PATH];
HMODULE hMod = GetModuleHandle(NULL);
GetModuleFileName(hMod, ourFile, _countof(ourFile));
if (!CopyFile(ourFile, machineInstallFolder, false)) {
return GetLastError();
}
HKEY runKey;
DWORD dontcare;
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &runKey, &dontcare) != ERROR_SUCCESS) {
return GetLastError();
}
wcscat_s(machineInstallFolder, L" --checkInstall");
if (RegSetValueEx(runKey, packageName, 0, REG_SZ, (BYTE*)machineInstallFolder, (wcsnlen(machineInstallFolder, sizeof(machineInstallFolder)) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS) {
return GetLastError();
}
RegCloseKey(runKey);
return 0;
}
示例2: smpd_set_smpd_data
int smpd_set_smpd_data(const char *key, const char *value)
{
#ifdef HAVE_WINDOWS_H
HKEY tkey;
DWORD len, result;
char err_msg[512];
smpd_enter_fn(FCNAME);
if (key == NULL || value == NULL)
{
smpd_exit_fn(FCNAME);
return SMPD_FAIL;
}
result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, SMPD_REGISTRY_KEY,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &tkey, NULL);
if (result != ERROR_SUCCESS)
{
smpd_translate_win_error(result, err_msg, 512, "Unable to open the HKEY_LOCAL_MACHINE\\" SMPD_REGISTRY_KEY " registry key, error %d\n", result);
smpd_err_printf("%s\n", err_msg);
smpd_exit_fn(FCNAME);
return SMPD_FAIL;
}
len = (DWORD)(strlen(value)+1);
result = RegSetValueEx(tkey, key, 0, REG_SZ, (const BYTE *)value, len);
if (result != ERROR_SUCCESS)
{
smpd_translate_win_error(result, err_msg, 512, "Unable to write the smpd registry value '%s:%s', error %d\n", key, value, result);
smpd_err_printf("%s\n", err_msg);
RegCloseKey(tkey);
smpd_exit_fn(FCNAME);
return SMPD_FAIL;
}
result = RegCloseKey(tkey);
if (result != ERROR_SUCCESS)
{
smpd_translate_win_error(result, err_msg, 512, "Unable to close the HKEY_LOCAL_MACHINE\\" SMPD_REGISTRY_KEY " registry key, error %d: ", result);
smpd_err_printf("%s\n", err_msg);
smpd_exit_fn(FCNAME);
return SMPD_FAIL;
}
smpd_exit_fn(FCNAME);
return SMPD_SUCCESS;
#else
int result;
smpd_data_t *list = NULL, *node;
int found = 0;
FILE *fout;
char *str;
int maxlen;
char buffer[1024];
char name_str[SMPD_MAX_NAME_LENGTH];
char value_str[SMPD_MAX_VALUE_LENGTH];
smpd_enter_fn(FCNAME);
smpd_dbg_printf("setting smpd data: %s=%s\n", key, value);
list = smpd_parse_smpd_file();
fout = smpd_open_smpd_file(SMPD_TRUE);
if (fout == NULL)
{
smpd_err_printf("Unable to open the .smpd file\n");
smpd_exit_fn(FCNAME);
return SMPD_FAIL;
}
while (list)
{
node = list;
list = list->next;
if (strcmp(key, node->name) == 0)
{
strcpy(node->value, value);
found = 1;
}
if (fout)
{
str = buffer;
maxlen = 1024;
if (MPIU_Str_add_string_arg(&str, &maxlen, node->name, node->value) == MPIU_STR_SUCCESS)
{
buffer[strlen(buffer)-1] = '\0'; /* remove the trailing space */
smpd_dbg_printf("writing '%s' to .smpd file\n", buffer);
fprintf(fout, "%s\n", buffer);
}
}
MPIU_Free(node);
}
if (!found && fout)
{
str = buffer;
maxlen = 1024;
if (MPIU_Str_add_string_arg(&str, &maxlen, key, value) == MPIU_STR_SUCCESS)
{
buffer[strlen(buffer)-1] = '\0'; /* remove the trailing space */
smpd_dbg_printf("writing '%s' to .smpd file\n", buffer);
//.........这里部分代码省略.........
示例3: Initialize
Error
Win32Prefs::
Initialize()
{
LONG result;
uint32 length;
char path[MAX_PATH] = {0x00};
char cwd[MAX_PATH]= {0x00};
Error error = kError_UnknownErr;
// Where are we starting the program from?
GetCurrentDirectory(sizeof(cwd), cwd);
if(m_prefsKey)
{
// people DO move their apps around on windows
length = sizeof(path);
error = GetPrefString(kInstallDirPref, path, &length);
char foo[MAX_PATH] = {0x00};
sprintf(foo,"%s\\freeamp.exe",cwd);
WIN32_FIND_DATA win32fd;
// check for freeamp exe in cwd
HANDLE h = FindFirstFile(foo, &win32fd);
if (h != INVALID_HANDLE_VALUE)
{
//if (win32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if(IsError(error) || strcmp(cwd, path))
{
result = RegSetValueEx( m_prefsKey,
kInstallDirPref,
NULL,
REG_SZ,
(LPBYTE)cwd,
strlen(cwd) + 1);
strcat(cwd, "\\db");
result = RegSetValueEx( m_prefsKey,
kDatabaseDirPref,
NULL,
REG_SZ,
(LPBYTE)cwd,
strlen(cwd) + 1);
}
}
FindClose(h);
}
error = kError_NoErr;
}
else // keys need to be created for the first time
{
DWORD disposition;
HKEY freeampKey;
HKEY versionKey;
// create the main key in the windows registry
result = RegCreateKeyEx(kMainKey,
kFreeAmpKey,
NULL,
"",
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&freeampKey,
&disposition);
if(result == ERROR_SUCCESS)
{
// create the version key under the freeamp key
result = RegCreateKeyEx(freeampKey,
kFreeAmpVersionKey,
NULL,
"",
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&versionKey,
&disposition);
}
if(result == ERROR_SUCCESS)
{
// create the version key under the freeamp key
result = RegCreateKeyEx(versionKey,
kMainComponentKey,
NULL,
"",
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&m_prefsKey,
&disposition);
}
//.........这里部分代码省略.........
示例4: RegisterServer
//---------------------------------------------------------------------------
// RegisterServer
// Create registry entries and setup the shell extension
//---------------------------------------------------------------------------
BOOL RegisterServer() {
int i;
HKEY hKey;
LRESULT lResult;
DWORD dwDisp;
TCHAR szSubKey[MAX_PATH];
TCHAR szModule[MAX_PATH];
TCHAR szDefaultPath[MAX_PATH];
GetModuleFileName(_hModule, szDefaultPath, MAX_PATH);
TCHAR* pDest = StrRChr(szDefaultPath, NULL, TEXT('\\'));
pDest++;
pDest[0] = 0;
lstrcat(szDefaultPath, szNppName);
if (!CheckNpp(szDefaultPath)) {
MsgBoxError(TEXT("To register the Notepad++ shell extension properly,\r\nplace NppShell.dll in the same directory as the Notepad++ executable."));
//return FALSE;
}
//get this app's path and file name
GetModuleFileName(_hModule, szModule, MAX_PATH);
static DOREGSTRUCT ClsidEntries[] = {
{HKEY_CLASSES_ROOT, TEXT("CLSID\\%s"), NULL, REG_SZ, szShellExtensionTitle},
{HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), NULL, REG_SZ, szModule},
{HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), TEXT("ThreadingModel"), REG_SZ, TEXT("Apartment")},
//Settings
// Context menu
{HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Title"), REG_SZ, szDefaultMenutext},
{HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Path"), REG_SZ, szDefaultPath},
{HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Custom"), REG_SZ, szDefaultCustomcommand},
{HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("ShowIcon"), REG_DWORD, (LPTSTR)&showIcon},
// Icon
{HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Dynamic"), REG_DWORD, (LPTSTR)&isDynamic},
{HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("Maxtext"), REG_DWORD, (LPTSTR)&maxText},
{HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Settings"), TEXT("IconID"), REG_DWORD, (LPTSTR)&iconID},
//Registration
// Context menu
{HKEY_CLASSES_ROOT, TEXT("*\\shellex\\ContextMenuHandlers\\Notepad++")sz64, NULL, REG_SZ, szGUID},
// Icon
//{HKEY_CLASSES_ROOT, TEXT("Notepad++_file\\shellex\\IconHandler"), NULL, REG_SZ, szGUID},
{NULL, NULL, NULL, REG_SZ, NULL}
};
// First clear any old entries
UnregisterServer();
// Register the CLSID entries
for(i = 0; ClsidEntries[i].hRootKey; i++) {
wsprintf(szSubKey, ClsidEntries[i].szSubKey, szGUID);
lResult = RegCreateKeyEx(ClsidEntries[i].hRootKey, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwDisp);
if (NOERROR == lResult) {
TCHAR szData[MAX_PATH];
// If necessary, create the value string
if (ClsidEntries[i].type == REG_SZ) {
wsprintf(szData, ClsidEntries[i].szData, szModule);
lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, ClsidEntries[i].type, (LPBYTE)szData, (lstrlen(szData) + 1) * sizeof(TCHAR));
} else {
lResult = RegSetValueEx(hKey, ClsidEntries[i].lpszValueName, 0, ClsidEntries[i].type, (LPBYTE)ClsidEntries[i].szData, sizeof(DWORD));
}
RegCloseKey(hKey);
}
else
return FALSE;
}
return TRUE;
}
示例5: WinMain
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HKL kl;
MessageBox(NULL,"DEBUG\n","Debug",0);
HKEY hk = NULL;
if( ERROR_SUCCESS != RegCreateKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\New Chewing IM", 0,
NULL, 0, KEY_ALL_ACCESS , NULL, &hk, NULL) )
hk = NULL;
printf("DEBUG\n");
if( strstr( lpCmdLine, "/uninstall" ) )
{
char temp[1024];
_gen_event_name(temp, sizeof(temp), "ChewingServer");
HWND hwnd = FindWindow(temp, NULL);
if ( hwnd ) {
SendMessage(hwnd, WM_DESTROY, 0, 0);
}
if( hk )
{
DWORD type = REG_DWORD, size = sizeof(DWORD);
if( ERROR_SUCCESS == RegQueryValueEx( hk, "KeyboardLayout", 0, &type, (LPBYTE)&kl, &size ) )
{
UnloadKeyboardLayout( kl );
char klstr[10];
wsprintf( klstr, "%X", kl );
char regpath[256];
lstrcpy( regpath, "Keyboard Layout\\Preload" );
HKEY hk2 = NULL;
// Windows NT only, 9x will be supported in the future
if( (GetVersion() < 0x80000000) )
{
if( ERROR_SUCCESS == RegOpenKey( HKEY_CURRENT_USER, regpath, &hk2 ) )
{
for( int i = 1; i <= 100; ++i )
{
char num[4];
wsprintf( num, "%d", i );
type = REG_SZ; size = sizeof(regpath);
if( ERROR_SUCCESS != RegQueryValueEx( hk2, num, 0, &type, (LPBYTE)regpath, &size ) )
continue;
if( 0 == lstrcmp( regpath, klstr ) )
{
RegDeleteValue( hk2, num );
break;
}
}
RegCloseKey(hk2);
}
}
wsprintf( regpath, "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s", klstr );
RegDeleteKey( HKEY_LOCAL_MACHINE, regpath );
}
}
}
else if ( strstr( lpCmdLine, "/privilege" ) )
{
enable_access("ch_index.dat");
enable_access("dict.dat");
enable_access("us_freq.dat");
enable_access("ph_index.dat");
enable_access("fonetree.dat");
}
else
{
char path[MAX_PATH];
GetSystemDirectory(path, MAX_PATH);
lstrcat( path, "\\Chewing.ime" );
printf("Install Path:%s\n",path);
kl = ImmInstallIME( path,
(GetVersion() < 0x80000000) ? "中文 (繁體) - 新酷音輸入法" : "新酷音輸入法" );
printf("Imm Install IME Result: %d\n",kl);
if( hk )
RegSetValueEx( hk, "KeyboardLayout", 0, REG_DWORD, (LPBYTE)&kl, sizeof(DWORD) );
}
RegCloseKey( hk );
return 0;
}
示例6: create_regkeys
int create_regkeys(char *identifier){
HKEY key,key2;
DWORD dispositions;
int i,j;
char *values[] = {
LATEST_RECORD_NAME,
LATEST_TIME_NAME,
NULL
};
DWORD zero = 0;
if(RegCreateKeyEx(HKEY_LOCAL_MACHINE,
APP_ROOT_KEY "\\" APP_SUB_KEY "\\"
APP_VERSION,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_CREATE_SUB_KEY,
NULL,
&key,
&dispositions) != ERROR_SUCCESS){
return -1;
}
if(RegCreateKeyEx(key,
identifier,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_CREATE_SUB_KEY,
NULL,
&key2,
&dispositions)){
RegCloseKey(key);
return -1;
}
RegCloseKey(key);
for(i=0; category_tab[i] != NULL; ++i){
if(RegCreateKeyEx(key2,
category_tab[i],
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_SET_VALUE,
NULL,
&key,
&dispositions) != ERROR_SUCCESS){
RegCloseKey(key2);
return -1;
}
for(j=0; values[j] != NULL; ++j){
if(RegSetValueEx(key,
values[j],
0,
REG_DWORD,
(BYTE *) &zero,
sizeof(DWORD)) != ERROR_SUCCESS){
RegCloseKey(key);
RegCloseKey(key2);
return -1;
}
}
RegCloseKey(key);
}
RegCloseKey(key2);
return 0;
}
示例7: lutil_srv_install
int lutil_srv_install(LPCTSTR lpszServiceName, LPCTSTR lpszDisplayName,
LPCTSTR lpszBinaryPathName, int auto_start)
{
HKEY hKey;
DWORD dwValue, dwDisposition;
SC_HANDLE schSCManager, schService;
char *sp = strchr( lpszBinaryPathName, ' ');
if ( sp ) *sp = '\0';
fprintf( stderr, "The install path is %s.\n", lpszBinaryPathName );
if ( sp ) *sp = ' ';
if ((schSCManager = OpenSCManager( NULL, NULL, SC_MANAGER_CONNECT|SC_MANAGER_CREATE_SERVICE ) ) != NULL )
{
if ((schService = CreateService(
schSCManager,
lpszServiceName,
lpszDisplayName,
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
auto_start ? SERVICE_AUTO_START : SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,
lpszBinaryPathName,
NULL, NULL, NULL, NULL, NULL)) != NULL)
{
char regpath[132];
CloseServiceHandle(schService);
CloseServiceHandle(schSCManager);
snprintf( regpath, sizeof regpath,
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s",
lpszServiceName );
/* Create the registry key for event logging to the Windows NT event log. */
if ( RegCreateKeyEx(HKEY_LOCAL_MACHINE,
regpath, 0,
"REG_SZ", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey,
&dwDisposition) != ERROR_SUCCESS)
{
fprintf( stderr, "RegCreateKeyEx() failed. GetLastError=%lu (%s)\n", GetLastError(), GetLastErrorString() );
RegCloseKey(hKey);
return(0);
}
if ( sp ) *sp = '\0';
if ( RegSetValueEx(hKey, "EventMessageFile", 0, REG_EXPAND_SZ, lpszBinaryPathName, strlen(lpszBinaryPathName) + 1) != ERROR_SUCCESS)
{
fprintf( stderr, "RegSetValueEx(EventMessageFile) failed. GetLastError=%lu (%s)\n", GetLastError(), GetLastErrorString() );
RegCloseKey(hKey);
return(0);
}
dwValue = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
if ( RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, (LPBYTE) &dwValue, sizeof(DWORD)) != ERROR_SUCCESS)
{
fprintf( stderr, "RegCreateKeyEx(TypesSupported) failed. GetLastError=%lu (%s)\n", GetLastError(), GetLastErrorString() );
RegCloseKey(hKey);
return(0);
}
RegCloseKey(hKey);
return(1);
}
else
{
fprintf( stderr, "CreateService() failed. GetLastError=%lu (%s)\n", GetLastError(), GetLastErrorString() );
CloseServiceHandle(schSCManager);
return(0);
}
}
else
fprintf( stderr, "OpenSCManager() failed. GetLastError=%lu (%s)\n", GetLastError(), GetLastErrorString() );
return(0);
}
示例8: MessageBox
// Dialog box handling functions
void
vncProperties::Show(BOOL show, BOOL usersettings)
{
if (show)
{
if (!m_allowproperties)
{
// If the user isn't allowed to override the settings then tell them
MessageBox(NULL, NO_OVERRIDE_ERR, "WinVNC Error", MB_OK | MB_ICONEXCLAMATION);
return;
}
// Verify that we know who is logged on
if (usersettings) {
char username[UNLEN+1];
if (!vncService::CurrentUser(username, sizeof(username)))
return;
if (strcmp(username, "") == 0) {
MessageBox(NULL, NO_CURRENT_USER_ERR, "WinVNC Error", MB_OK | MB_ICONEXCLAMATION);
return;
}
} else {
// We're trying to edit the default local settings - verify that we can
HKEY hkLocal, hkDefault;
BOOL canEditDefaultPrefs = 1;
DWORD dw;
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
WINVNC_REGISTRY_KEY,
0, REG_NONE, REG_OPTION_NON_VOLATILE,
KEY_READ, NULL, &hkLocal, &dw) != ERROR_SUCCESS)
canEditDefaultPrefs = 0;
else if (RegCreateKeyEx(hkLocal,
"Default",
0, REG_NONE, REG_OPTION_NON_VOLATILE,
KEY_WRITE | KEY_READ, NULL, &hkDefault, &dw) != ERROR_SUCCESS)
canEditDefaultPrefs = 0;
if (hkLocal) RegCloseKey(hkLocal);
if (hkDefault) RegCloseKey(hkDefault);
if (!canEditDefaultPrefs) {
MessageBox(NULL, CANNOT_EDIT_DEFAULT_PREFS, "WinVNC Error", MB_OK | MB_ICONEXCLAMATION);
return;
}
}
// Now, if the dialog is not already displayed, show it!
if (!m_dlgvisible)
{
if (usersettings)
vnclog.Print(LL_INTINFO, VNCLOG("show per-user Properties\n"));
else
vnclog.Print(LL_INTINFO, VNCLOG("show default system Properties\n"));
// Load in the settings relevant to the user or system
Load(usersettings);
for (;;)
{
m_returncode_valid = FALSE;
// Do the dialog box
int result = DialogBoxParam(hAppInstance,
MAKEINTRESOURCE(IDD_PROPERTIES),
NULL,
(DLGPROC) DialogProc,
(LONG) this);
if (!m_returncode_valid)
result = IDCANCEL;
vnclog.Print(LL_INTINFO, VNCLOG("dialog result = %d\n"), result);
if (result == -1)
{
// Dialog box failed, so quit
PostQuitMessage(0);
return;
}
// We're allowed to exit if the password is not empty
char passwd[MAXPWLEN];
m_server->GetPassword(passwd);
{
vncPasswd::ToText plain(passwd);
if ((strlen(plain) != 0) || !m_server->AuthRequired())
break;
}
vnclog.Print(LL_INTERR, VNCLOG("warning - empty password\n"));
// The password is empty, so if OK was used then redisplay the box,
// otherwise, if CANCEL was used, close down WinVNC
if (result == IDCANCEL)
{
vnclog.Print(LL_INTERR, VNCLOG("no password - QUITTING\n"));
PostQuitMessage(0);
return;
}
//.........这里部分代码省略.........
示例9: strcpy
void
vncProperties::Load(BOOL usersettings)
{
// Initialize to 'sane' defaults for our purposes
m_pref_QuerySetting=2;
m_pref_QueryTimeout=10;
m_pref_IdleTimeout=0;
m_pref_EnableRemoteInputs=TRUE;
m_pref_DisableLocalInputs=TRUE;
m_pref_PollUnderCursor=FALSE;
m_pref_PollForeground=TRUE;
m_pref_PollFullScreen=TRUE;
return;
char username[UNLEN+1];
HKEY hkLocal, hkLocalUser, hkDefault;
DWORD dw;
// NEW (R3) PREFERENCES ALGORITHM
// 1. Look in HKEY_LOCAL_MACHINE/Software/ORL/WinVNC3/%username%
// for sysadmin-defined, user-specific settings.
// 2. If not found, fall back to %username%=Default
// 3. If AllowOverrides is set then load settings from
// HKEY_CURRENT_USER/Software/ORL/WinVNC3
// GET THE CORRECT KEY TO READ FROM
// Get the user name / service name
if (!vncService::CurrentUser((char *)&username, sizeof(username)))
return;
// If there is no user logged on them default to SYSTEM
if (strcmp(username, "") == 0)
strcpy((char *)&username, "SYSTEM");
// Try to get the machine registry key for WinVNC
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
WINVNC_REGISTRY_KEY,
0, REG_NONE, REG_OPTION_NON_VOLATILE,
KEY_READ, NULL, &hkLocal, &dw) != ERROR_SUCCESS)
return;
// Now try to get the per-user local key
if (RegOpenKeyEx(hkLocal,
username,
0, KEY_READ,
&hkLocalUser) != ERROR_SUCCESS)
hkLocalUser = NULL;
// Get the default key
if (RegCreateKeyEx(hkLocal,
"Default",
0, REG_NONE, REG_OPTION_NON_VOLATILE,
KEY_READ,
NULL,
&hkDefault,
&dw) != ERROR_SUCCESS)
hkDefault = NULL;
// LOAD THE MACHINE-LEVEL PREFS
// Logging/debugging prefs
vnclog.Print(LL_INTINFO, VNCLOG("loading local-only settings\n"));
vnclog.SetMode(LoadInt(hkLocal, "DebugMode", 0));
vnclog.SetLevel(LoadInt(hkLocal, "DebugLevel", 0));
// Authentication required, loopback allowed, loopbackOnly
m_server->SetLoopbackOnly(LoadInt(hkLocal, "LoopbackOnly", false));
if (m_server->LoopbackOnly())
m_server->SetLoopbackOk(true);
else
m_server->SetLoopbackOk(LoadInt(hkLocal, "AllowLoopback", false));
m_server->SetAuthRequired(LoadInt(hkLocal, "AuthRequired", true));
m_server->SetConnectPriority(LoadInt(hkLocal, "ConnectPriority", 0));
if (!m_server->LoopbackOnly())
{
char *authhosts = LoadString(hkLocal, "AuthHosts");
if (authhosts != 0) {
m_server->SetAuthHosts(authhosts);
delete [] authhosts;
} else {
m_server->SetAuthHosts(0);
}
} else {
m_server->SetAuthHosts(0);
}
// LOAD THE USER PREFERENCES
// Set the default user prefs
vnclog.Print(LL_INTINFO, VNCLOG("clearing user settings\n"));
m_pref_HTTPConnect = TRUE;
m_pref_AutoPortSelect=TRUE;
m_pref_PortNumber=5900;
m_pref_SockConnect=TRUE;
m_pref_CORBAConn=FALSE;
{
vncPasswd::FromClear crypt;
memcpy(m_pref_passwd, crypt, MAXPWLEN);
//.........这里部分代码省略.........
示例10: _T
BOOL CLoadDll::LoadExtendLibrary()
{
if (!m_xmlMarkup.IsWellFormed())
{
return FALSE;
}
if (m_bHaveExtend)
{
TCHAR cPath[MAX_PATH] = {0};
::GetModuleFileName(NULL,cPath,MAX_PATH);
CString strPath = cPath;
int nPos = strPath.ReverseFind('\\');
CString strName = strPath.Mid(nPos+1);
//if(strName.CompareNoCase(_T("communicator.exe")))
// return false;
wchar_t buf[_MAX_PATH];
CString strLyncPath = _T("");
strPath = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\");
strPath += strName;
swprintf_s(buf,strPath);
HKEY hKey=NULL;
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,buf,0,NULL,REG_OPTION_NON_VOLATILE,KEY_READ|KEY_QUERY_VALUE|KEY_WOW64_64KEY,NULL,&hKey,NULL)==ERROR_SUCCESS)
{
wchar_t path[_MAX_PATH];
DWORD size=_MAX_PATH;
if (RegQueryValueEx(hKey,L"Path",0,NULL,(BYTE*)&path,&size)==ERROR_SUCCESS)
{
strLyncPath = path;
}
RegCloseKey(hKey);
}
TCHAR szPath[MAX_PATH] = {0};
HRESULT hr = SHGetFolderPath(NULL,CSIDL_COMMON_APPDATA,NULL,0,szPath);
wchar_t path[_MAX_PATH*2];
GetTempPath(_countof(path),path);
CString strFile = CString(path);
strFile += _T("LyncPlusUpdate\\Lyncplus.xml");
BOOL bExist=PathFileExists(strFile);
MCD_STR strMsi = _T("");
if(bExist)
{
CMarkup _xmlMarkup;
if(_xmlMarkup.Load(strFile.GetBuffer()))
{
if (bFindNode(&_xmlMarkup,_T("AutoUpdate")))
{
strMsi = _xmlMarkup.GetAttrib(_T("Msi"));
MCD_STR strVer = _xmlMarkup.GetAttrib(_T("ver"));
CString _strVer = strVer.c_str();
if(_strVer!=m_strCurVer)
{
CString _strFile = CString(path);
_strFile += _T("LyncPlusUpdate\\");
_strFile += strMsi.c_str();
bExist=PathFileExists(_strFile);
if(bExist)
{
STARTUPINFO startupInfo;
memset(&startupInfo,0,sizeof(startupInfo));
startupInfo.cb=sizeof(startupInfo);
PROCESS_INFORMATION processInfo;
memset(&processInfo,0,sizeof(processInfo));
wchar_t cmdLine[2048];
//swprintf_s(cmdLine,L"msiexec.exe /i \"%s\" %s",_strFile, _T("/qb"));
swprintf_s(cmdLine,_T("msiexec.exe /i \"%s\" TARGETDIR=\"%s\" %s"),_strFile,strLyncPath, _T("/qb"));
//swprintf_s(cmdLine,L"msiexec.exe /i \"%s\" REINSTALLMODE=\"amus\" /norestart TARGETDIR=\"%s\" %s",_strFile,strLyncPath, _T("/qb"));
//swprintf_s(cmdLine,L"msiexec.exe /i \"%s\" %s",_strFile,_T("/qn"));
DWORD code;
if (!CreateProcess(NULL,cmdLine,NULL,NULL,TRUE,0,NULL,NULL,&startupInfo,&processInfo))
{
//DeleteFile(_strFile);
}
else
{
// wait for the installer to finish
WaitForSingleObject(processInfo.hProcess,INFINITE);
DeleteFile(_strFile);
GetExitCodeProcess(processInfo.hProcess,&code);
}
}
}
}
}
}
//STARTUPINFO startupInfo;
//wchar_t cmdLine[2048];
//memset(&startupInfo,0,sizeof(startupInfo));
//startupInfo.cb=sizeof(startupInfo);
//PROCESS_INFORMATION processInfo;
//memset(&processInfo,0,sizeof(processInfo));
//swprintf_s(cmdLine,L"%s %s",strProcess.c_str(), strFile);
////swprintf_s(cmdLine,L"msiexec.exe /i \"%s\" %s",m_strAppDataPath,_T("/qb"));tangramManager.exe
//DWORD code;
//if (!CreateProcess(NULL,cmdLine,NULL,NULL,TRUE,0,NULL,NULL,&startupInfo,&processInfo))
//.........这里部分代码省略.........
示例11: QWidget
NewDeviceWidget::NewDeviceWidget(QWidget *parent, QString MACAddress)
: QWidget(parent)
{
MAC = MACAddress;
backgroundPalette.setBrush(QPalette::Background, QColor(234, 237, 242));
descriptionTextPalette.setColor(QPalette::WindowText, QColor(51, 51, 51));
errorTextPalette.setColor(QPalette::WindowText, QColor(255, 150, 0, 255));
/* Set the layout and initial settings for the New Device widget */
this->setLayout(new QVBoxLayout()); //Use a Vertical Box Layout
this->layout()->setSpacing(0); //Clear the spacing between any child widgets
this->layout()->setAlignment(Qt::AlignTop); //Align layout contents at the top of the widget
this->setAutoFillBackground(true); //Don't fill in a background color
this->setPalette(backgroundPalette);
this->setGeometry(1 /* in */, 100 /* down */, 798 /* width */, 539 /* height */);
/* Draw the Device Name text label and input field */
deviceNameLabel = new QLabel(); //Initialize the QLabel pointer
deviceNameLabel->setText(deviceNameText); //Set the text
deviceNameLabel->setFont(QFont("Segoe UI", 12));
deviceNameLabel->setPalette(descriptionTextPalette); //Set the text color
deviceNameLabel->setContentsMargins(0, 100, 0, 6); //Pad the label down 100 from the logo and up 4 from the next object
deviceNameLabel->setAlignment(Qt::AlignCenter); //Center the text within the QLabel
deviceNameInput = new QLineEdit(); //Initialize the QLineEdit pointer
deviceNameInput->setText(""); //Set the text
deviceNameInput->setFont(QFont("Segoe UI", 10));
deviceNameInput->setFixedWidth(200); //Set a fixed size for the field
deviceNameInput->setAlignment(Qt::AlignCenter); //Center the text within the field
this->layout()->addWidget(deviceNameLabel); //Add it to the Start widget layout
this->layout()->addWidget(deviceNameInput); //Add it to the Start widget layout
this->layout()->setAlignment(deviceNameLabel, Qt::AlignHCenter); //And align it in the center of the widget
this->layout()->setAlignment(deviceNameInput, Qt::AlignHCenter); //And align it in the center of the widget
/* Draw the Internet Connection text label and combo box */
deviceTypeLabel = new QLabel(); //Initialize the QLabel pointer
deviceTypeLabel->setText(deviceTypeText); //Set the text
deviceTypeLabel->setFont(QFont("Segoe UI", 12));
deviceTypeLabel->setPalette(descriptionTextPalette); //Set the text color
deviceTypeLabel->setContentsMargins(0, 20, 0, 6); //Pad the label down 20 from the line edit and up 4 from the next object
deviceTypeLabel->setAlignment(Qt::AlignCenter); //Center the text within the QLabel
deviceTypeComboBox = new NComboBox(); //Initialize the QComboBox pointer
deviceTypeComboBox->setFixedWidth(200); //Set a fixed size for the field
deviceTypeComboBox->setFont(QFont("Segoe UI", 10));
this->layout()->addWidget(deviceTypeLabel); //Add it to the Start widget layout
this->layout()->addWidget(deviceTypeComboBox); //Add it to the Start widget layout
this->layout()->setAlignment(deviceTypeLabel, Qt::AlignHCenter); //And align it in the center of the widget
this->layout()->setAlignment(deviceTypeComboBox, Qt::AlignHCenter); //And align it in the center of the widget
/* Set QComboBox's LineEdit as editable and read only in order to center the text */
deviceTypeComboBox->setEditable(true);
deviceTypeComboBox->lineEdit()->setReadOnly(true);
deviceTypeComboBox->lineEdit()->setContentsMargins(18, 0, 0, 0);
deviceTypeComboBox->lineEdit()->setAlignment(Qt::AlignCenter); //Only possible when LineEdit is editable
deviceTypeComboBox->lineEdit()->setAttribute(Qt::WA_TransparentForMouseEvents); //Allows QComboBox to still display dropdown on click
/* Populate the QComboBox with the network adapter friendly names */
for (int i = 0; i < NUM_DEVICE_TYPES; i++)
{
deviceTypeComboBox->addItem(DeviceNames[i]); //Add the friendly name from the QList
deviceTypeComboBox->setItemData(i, Qt::AlignCenter, Qt::TextAlignmentRole); //Center the text
}
/* Draw the Start button */
setButton = new QPushButton(); //Initialize the Start button pointer
setButton->setStyleSheet(setButtonStyleSheet); //Set the style sheet to get the background images for button states
setButton->setFixedSize(90, 30); //Set a fixed button size (#s from the dimensions of the button images)
setButton->setText("Save");
connect(setButton, &QPushButton::clicked, this, &NewDeviceWidget::onSetButtonClicked);
this->layout()->addItem(new QSpacerItem(0, 30)); //Pad down from the internet connection combo box
this->layout()->addWidget(setButton); //Add the start button to the Start widget layout
this->layout()->setAlignment(setButton, Qt::AlignHCenter); //And align it in the center of the layout
/* Open a handle to the Inssidious Registry key and read in known device names and types */
bool haveName = false;
bool haveType = false;
HKEY inssidiousDevicePairsHKCU;
if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\Inssidious\\DevicePairs", 0, 0, 0, KEY_WRITE | KEY_QUERY_VALUE, 0, &inssidiousDevicePairsHKCU, 0))
{
DWORD numValues = 0;
if (ERROR_SUCCESS == RegQueryInfoKey(inssidiousDevicePairsHKCU, 0, 0, 0, 0, 0, 0, &numValues, 0, 0, 0, 0))
{
for (int i = 0; i < numValues; i++)
{
wchar_t valueName[MAX_PATH];
//.........这里部分代码省略.........
示例12: set_registry_from_env
static void
set_registry_from_env(const TCHAR *image_name, const TCHAR *dll_path)
{
#undef TEMP_CMD
#define TEMP_CMD(name, NAME) \
BOOL do_##name; \
TCHAR name##_value[MAX_REGISTRY_PARAMETER]
DO_ENV_VARS();
DWORD disp, size, type;
int res, len;
int rununder_int_value;
/* get environment variable values if they are set */
#undef TEMP_CMD
#define TEMP_CMD(name, NAME) \
name##_value[0] = '\0'; /* to be pedantic */ \
len = GetEnvironmentVariable(_TEXT(DYNAMORIO_VAR_##NAME), name##_value, \
BUFFER_SIZE_ELEMENTS(name##_value)); \
do_##name = (use_environment && \
(len > 0 || \
(len == 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND))); \
ASSERT(len < BUFFER_SIZE_ELEMENTS(name##_value)); \
VERBOSE_PRINT(("Environment var %s for %s, value = %s\n", \
do_##name ? "set" : "not set", #name, name##_value));
DO_ENV_VARS();
if (ops_param != NULL) {
/* -ops overrides env var */
strncpy(options_value, ops_param, BUFFER_SIZE_ELEMENTS(options_value));
NULL_TERMINATE_BUFFER(options_value);
do_options = TRUE;
}
/* we always want to set the rununder to make sure RUNUNDER_ON is on
* to support following children; we set RUNUNDER_EXPLICIT to allow
* injecting even when preinject is configured. */
/* FIXME: we read only decimal */
rununder_int_value = _ttoi(rununder_value);
rununder_int_value |= RUNUNDER_ON | RUNUNDER_EXPLICIT;
do_rununder = true;
_itot(rununder_int_value, rununder_value,
10 /* FIXME : is the radix abstracted somewhere */);
/* for follow_children, we set DYNAMORIO_AUTOINJECT (unless
* overridden by env var: then child will use env value, while
* parent uses cmdline path) */
if (!do_autoinject && dll_path != NULL) {
_tcsncpy(autoinject_value, dll_path, BUFFER_SIZE_ELEMENTS(autoinject_value));
do_autoinject = true;
}
/* FIXME : doesn't support svchost-* yet */
ASSERT(_tcsicmp(_TEXT(SVCHOST_EXE_NAME), image_name));
res = RegCreateKeyEx(DYNAMORIO_REGISTRY_HIVE,
_TEXT(DYNAMORIO_REGISTRY_KEY), 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, NULL,
&product_name_key, &disp);
ASSERT(res == ERROR_SUCCESS);
if (disp == REG_CREATED_NEW_KEY) {
created_product_reg_key = TRUE;
}
res = RegCreateKeyEx(product_name_key, image_name, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE|KEY_SET_VALUE,
NULL, &image_name_key, &disp);
ASSERT(res == ERROR_SUCCESS);
if (disp == REG_CREATED_NEW_KEY) {
created_image_reg_key = TRUE;
}
DO_VERBOSE({
printf("created product key? %s\ncreated image key? %s\n",
created_product_reg_key ? "yes" : "no",
created_image_reg_key ? "yes" : "no");
fflush(stdout);
});
示例13: _T
HRESULT PowerDocsExtHelper::SetupEventHandler()
{
DWORD dwDisposition;
HKEY hKey;
LPTSTR lpClass = NULL;
TCHAR szSubKey[ MAX_PATH ];
TCHAR szPath[MAX_PATH];
DWORD dwSize = MAX_PATH;
bool bPowerDocsInstalled = FALSE;
HRESULT hr = S_OK;
CStdString sKeyName = _T("SOFTWARE\\Hummingbird\\PowerDOCS\\OM\\EventHandlers\\DeltaView");
CStdString sKeyName31 = _T("SOFTWARE\\PC DOCS Inc.\\PowerDOCS\\OM\\EventHandlers\\DeltaView");
// Is PowerDocs greater than 5.0 installed?
if (IsPowerDocsGreaterThan50Installed())
{
if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Hummingbird\\PowerDOCS"), 0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS )
{
if( RegQueryValueEx( hKey, _T("InstallPath"), 0, 0, (unsigned char*)szPath, &dwSize ) == ERROR_SUCCESS )
{
_tcsncpy( szSubKey, sKeyName.c_str(), 100 );
bPowerDocsInstalled = TRUE;
}
RegCloseKey(hKey);
}
}
// Is PowerDocs 4.0 installed?
else if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Hummingbird\\PowerDOCS 4.0"), 0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS )
{
if( RegQueryValueEx( hKey, _T("Path"), 0, 0, (unsigned char*)szPath, &dwSize ) == ERROR_SUCCESS )
{
_tcsncpy( szSubKey, sKeyName.c_str(), 100 );
bPowerDocsInstalled = TRUE;
}
RegCloseKey(hKey);
}
// Is PowerDocs 3.9 installed?
else if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Hummingbird\\PowerDOCS 3.9"), 0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS )
{
if( RegQueryValueEx( hKey, _T("Path"), 0, 0, (unsigned char*)szPath, &dwSize ) == ERROR_SUCCESS )
{
_tcsncpy( szSubKey, sKeyName.c_str(), 100 );
bPowerDocsInstalled = TRUE;
}
RegCloseKey(hKey);
}
// If PowerDocs 3.9 is not installed, is PowerDocs 3.1 installed?
else if( (bPowerDocsInstalled == FALSE) &&
(RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("SOFTWARE\\PC DOCS Inc.\\PowerDOCS\\Installation"), 0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS ))
{
if( RegQueryValueEx( hKey, _T("Path"), 0, 0, (unsigned char*)szPath, &dwSize ) == ERROR_SUCCESS )
{
_tcsncpy( szSubKey, sKeyName31.c_str(), 100 );
bPowerDocsInstalled = TRUE;
}
RegCloseKey(hKey);
}
// If PowerDocs is installed, install the event handler
if (bPowerDocsInstalled)
{
long lRet = ERROR_SUCCESS;
lRet = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
(LPCTSTR)szSubKey ,
(DWORD)0,
lpClass,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisposition );
if (lRet == ERROR_SUCCESS)
{
TCHAR szValueData[] = _T(_VERPROGID_PowerDocsExt);
DWORD dwByteCout = (x64_int_cast)_tcslen(szValueData) * sizeof(TCHAR);
RegSetValueEx(hKey, _T(""), (DWORD)0, REG_SZ, (CONST BYTE *)szValueData, dwByteCout);
RegCloseKey( hKey );
}
else
{
hr = HRESULT_FROM_WIN32(lRet);
}
}
else
{
hr = E_PD_NOT_INSTALLED;
}
return hr;
}
示例14: main
//.........这里部分代码省略.........
//MessageBox(NULL, "PBO extract failed", "cpbo", MB_ICONSTOP);
MessageBox(NULL, "Extract of one or more files failed", "cpbo", MB_ICONSTOP);
#endif
return -1;
}
}
if(!strcasecmp("-p", argv[ai])) {
if(argc-ai < 2)
usage();
char *last = argv[ai+1] + strlen(argv[ai+1]) - 1;
if (*last == '/' || *last == '\\') // If directory path has trailing slash then remove it (replace with null terminator)
*last = '\0';
// Create PBO.
char *ofile = "";
if(argc >= ai+3)
ofile = argv[ai+2];
printf("Creating %s\n", argv[ai+1]);
if(pboPack(argv[ai+1], ofile, overwrite)) {
printf("Done.\n");
return 1;
} else {
printf("Failed!\n");
#ifndef _NIX
MessageBox(NULL, "PBO creation failed", "cpbo", MB_ICONSTOP);
#endif
return -1;
}
}
#ifndef _NIX
if(!strcasecmp("-a", argv[ai])) {
assign:
// Create file associations
char foo[1024];
GetModuleFileName(NULL, foo, 1024);
printf("%s\n", foo);
// for PBO...
HKEY hKey;
DWORD dwDisp = 0;
LPDWORD lpdwDisp = &dwDisp;
DWORD dwVal = 100;
LONG ret = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".pbo\\shell\\Extract\\command", 0L,NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey,lpdwDisp);
if(ret == ERROR_SUCCESS) {
char foo2[1024];
sprintf(foo2, "\"%s\" -e \"%%1\"", foo);
RegSetValueEx(hKey, NULL, 0L, REG_SZ, (const BYTE *) foo2, strlen(foo2));
RegCloseKey(hKey);
} else
printf("PBO association failed! Verify registry permissions\n");
ret = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".pbo\\shell\\extract PBO...\\command", 0L,NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey,lpdwDisp);
if(ret == ERROR_SUCCESS) {
char foo2[1024];
sprintf(foo2, "\"%s\" -gui -e \"%%1\"", foo);
RegSetValueEx(hKey, NULL, 0L, REG_SZ, (const BYTE *) foo2, strlen(foo2));
RegCloseKey(hKey);
} else
printf("PBO association failed! Verify registry permissions\n");
// For directories
ret = RegCreateKeyEx(HKEY_CLASSES_ROOT, "Folder\\shell\\create PBO\\command", 0L,NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey,lpdwDisp);
if(ret == ERROR_SUCCESS) {
char foo2[1024];
sprintf(foo2, "\"%s\" -p \"%%1\"", foo);
RegSetValueEx(hKey, NULL, 0L, REG_SZ, (const BYTE *) foo2, strlen(foo2));
RegCloseKey(hKey);
} else
printf("Directory association failed! Verify registry permissions\n");
// PBO Icon
ret = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".pbo\\DefaultIcon", 0L,NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, lpdwDisp);
if(ret == ERROR_SUCCESS) {
if(dwDisp == REG_CREATED_NEW_KEY) {
// Set new icon
char foo2[1024];
sprintf(foo2, "%s,0", foo);
RegSetValueEx(hKey, NULL, 0L, REG_SZ, (const BYTE *) foo2, strlen(foo2));
} else
printf("Default PBO icon already exists, not overwritten\n");
RegCloseKey(hKey);
}
printf("Done.\n");
if(runDirectly)
MessageBox(NULL, "Done", "cpbo", MB_ICONINFORMATION);
return 1;
}
#endif
}
}
示例15: DllRegisterServer
STDAPI DllRegisterServer (VOID)
{
TCHAR szModuleName[MAX_PATH];
HRESULT hResult = S_OK;
TCHAR szBuffer[MAX_PATH+10] = TEXT("");
TCHAR szClsid[MAX_PATH] = TEXT("");
TCHAR szSubKey[MAX_PATH] = TEXT("");
TCHAR szColumnProvider[MAX_PATH] = TEXT("");
TCHAR szDescription[MAX_PATH] = TEXT("");
SECURITY_ATTRIBUTES SA;
SA.nLength = sizeof(SECURITY_ATTRIBUTES);
SA.bInheritHandle = TRUE;
WCHAR *pwszSD=L"D:(A;OICI;GA;;;SY)(A;OICI;GA;;;BA)(A;OICI;GA;;;CO)(A;OICI;GRGWGX;;;IU)";
//
// Load some necessary string values
//
//
// Initialize the security attributes structure
//
if (ConvertStringSecurityDescriptorToSecurityDescriptor(pwszSD,
SDDL_REVISION_1,
&(SA.lpSecurityDescriptor),
NULL))
{
LoadString (hDllInstance, IDS_CLSID, szClsid, MAX_PATH);
LoadString (hDllInstance, IDS_DESCRIPTION, szDescription, MAX_PATH);
LoadString (hDllInstance, IDS_REGKEY_COLUMNPROVIDER, szColumnProvider, MAX_PATH);
//
// Get the name of this module
//
GetModuleFileName (hDllInstance, szModuleName, MAX_PATH);
//
// Register the component under HKCR\CLSID
//
HKEY hKey = NULL;
DWORD dwDisposition = 0;
LRESULT lResult = 0;
wsprintf (szSubKey, TEXT("CLSID\\%s"), szClsid);
lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
&SA, &hKey, &dwDisposition);
if (lResult == NOERROR)
{
lResult = RegSetValueEx (hKey, TEXT(""), 0, REG_SZ,
(LPBYTE) szDescription, GetStringByteSize(szDescription));
if (lResult != NOERROR)
hResult = SELFREG_E_CLASS;
RegCloseKey (hKey);
hKey = NULL;
}
else
{
hResult = SELFREG_E_CLASS;
}
//
// Register component information under HKCR\CLSID\{CLSID}
//
StrCatBuff (szSubKey, TEXT("\\InprocServer32"), ARRAYSIZE(szSubKey));
lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
&SA, &hKey, &dwDisposition);
if (lResult == NOERROR)
{
lstrcpyn (szBuffer, TEXT("Apartment"), ARRAYSIZE(szBuffer));
lResult = RegSetValueEx (hKey, TEXT("ThreadingModel"), 0,
REG_SZ, (LPBYTE) szBuffer, GetStringByteSize (szBuffer));
if (lResult != NOERROR)
hResult = SELFREG_E_CLASS;
lResult = RegSetValueEx (hKey, TEXT(""), 0,
REG_SZ, (LPBYTE) szModuleName, GetStringByteSize(szModuleName));
if (lResult != NOERROR)
hResult = SELFREG_E_CLASS;
RegCloseKey (hKey);
hKey = NULL;
}
else
{
hResult = SELFREG_E_CLASS;
}
//
// Register the component as a column provider extension under
// HKCR\Folder\shellex\ColumnHandlers
//
wsprintf (szSubKey, TEXT("%s\\%s"), szColumnProvider, szClsid);
lResult = RegCreateKeyEx (HKEY_CLASSES_ROOT, szSubKey,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
&SA, &hKey, &dwDisposition);
if (lResult != NOERROR)
//.........这里部分代码省略.........