本文整理汇总了C++中RegQueryValueEx函数的典型用法代码示例。如果您正苦于以下问题:C++ RegQueryValueEx函数的具体用法?C++ RegQueryValueEx怎么用?C++ RegQueryValueEx使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RegQueryValueEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PHP_FUNCTION
/* {{{ proto int pspell_config_create(string language [, string spelling [, string jargon [, string encoding]]])
Create a new config to be used later to create a manager */
static PHP_FUNCTION(pspell_config_create)
{
char *language, *spelling = NULL, *jargon = NULL, *encoding = NULL;
size_t language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0;
zval *ind;
PspellConfig *config;
#ifdef PHP_WIN32
TCHAR aspell_dir[200];
TCHAR data_dir[220];
TCHAR dict_dir[220];
HKEY hkey;
DWORD dwType,dwLen;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|sss", &language, &language_len, &spelling, &spelling_len,
&jargon, &jargon_len, &encoding, &encoding_len) == FAILURE) {
return;
}
config = new_pspell_config();
#ifdef PHP_WIN32
/* If aspell was installed using installer, we should have a key
* pointing to the location of the dictionaries
*/
if (0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) {
LONG result;
dwLen = sizeof(aspell_dir) - 1;
result = RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen);
RegCloseKey(hkey);
if (result == ERROR_SUCCESS) {
strlcpy(data_dir, aspell_dir, sizeof(data_dir));
strlcat(data_dir, "\\data", sizeof(data_dir));
strlcpy(dict_dir, aspell_dir, sizeof(dict_dir));
strlcat(dict_dir, "\\dict", sizeof(dict_dir));
pspell_config_replace(config, "data-dir", data_dir);
pspell_config_replace(config, "dict-dir", dict_dir);
}
}
#endif
pspell_config_replace(config, "language-tag", language);
if (spelling_len) {
pspell_config_replace(config, "spelling", spelling);
}
if (jargon_len) {
pspell_config_replace(config, "jargon", jargon);
}
if (encoding_len) {
pspell_config_replace(config, "encoding", encoding);
}
/* By default I do not want to write anything anywhere because it'll try to write to $HOME
which is not what we want */
pspell_config_replace(config, "save-repl", "false");
ind = zend_list_insert(config, le_pspell_config);
RETURN_LONG(Z_RES_HANDLE_P(ind));
}
示例2: get_available_wsls
bool get_available_wsls(std::vector<std::string>& wsls, std::string& default_wsl) {
const std::string lxss_path = "Software\\Microsoft\\Windows\\CurrentVersion\\Lxss";
HKEY hKey;
default_wsl = "";
LONG lRet = RegOpenKeyEx(HKEY_CURRENT_USER,
lxss_path.c_str(),
0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hKey);
if (lRet != ERROR_SUCCESS)
return false;
const int buf_len = 256;
char default_wsl_guid[buf_len];
DWORD default_wsl_guid_len = sizeof(default_wsl_guid);
lRet = RegQueryValueEx(hKey, "DefaultDistribution", NULL, NULL,
(LPBYTE)default_wsl_guid, &default_wsl_guid_len);
if ((lRet != ERROR_SUCCESS) || (default_wsl_guid_len > buf_len))
return false;
int i = 0;
while(true) {
char wsl_guid[buf_len];
DWORD wsl_guid_len = sizeof(wsl_guid);
LONG ret = RegEnumKeyEx(hKey, i++, wsl_guid, &wsl_guid_len,
NULL, NULL, NULL, NULL);
if (ret != ERROR_SUCCESS) {
break;
}
HKEY hSubKey;
const std::string sub_key = lxss_path + "\\" + wsl_guid;
ret = RegOpenKeyEx(HKEY_CURRENT_USER,
sub_key.c_str(),
0, KEY_QUERY_VALUE, &hSubKey);
if (ret != ERROR_SUCCESS) {
break;
}
char wsl_name[buf_len];
DWORD wsl_name_len = sizeof(wsl_name);
DWORD wsl_state = 0;
DWORD wsl_state_len = sizeof(wsl_state);
ret = RegQueryValueEx(hSubKey, "State", NULL, NULL, (LPBYTE)&wsl_state, &wsl_state_len);
if (ret != ERROR_SUCCESS || wsl_state != 1) {
continue;
}
ret = RegQueryValueEx(hSubKey, "DistributionName", NULL, NULL,
(LPBYTE)wsl_name, &wsl_name_len);
if ((ret == ERROR_SUCCESS) && (wsl_name_len < buf_len)) {
wsls.push_back(wsl_name);
if (std::string(wsl_guid) == std::string(default_wsl_guid)) {
default_wsl = wsl_name;
}
RegCloseKey(hSubKey);
}
}
RegCloseKey(hKey);
return default_wsl != "";
}
示例3: sys_GetRegKey
// ------------------------------------------------
//
// FUNCTION: sys_GetRegKey( PA_PluginParameters params )
//
// PURPOSE: Get a key from the registry.
//
// DATE: MJG 12/4/03 (3.5.6)
//
void sys_GetRegKey( PA_PluginParameters params )
{
LONG_PTR returnValue, regKey, retErr, dataSize, arraySize, expandDataSize;
LONG_PTR i, len;
char regSub[MAXBUF];
char regName[MAXBUF];
char *returnDataBuffer, *ptrData;
HKEY hRootKey;
HKEY hOpenKey;
DWORD dwDataType;
DWORD dwReturnLong;
PA_Variable paReturnArray;
// AMS2 12/9/14 #41400 Initalized the dataSize variable. In 64 bit environments this can be randomly initalized to a size in bytes
// that is larger than malloc can allot, causing it to return null and crash when returning to 4D. Remember to always initialize your size variables.
dataSize = 0;
returnValue = regKey = retErr = arraySize = expandDataSize = 0;
hRootKey = hOpenKey = 0;
ptrData = returnDataBuffer = NULL;
memset(regSub, 0, MAXBUF);
memset(regName, 0, MAXBUF);
// Get the function parameters.
regKey = PA_GetLongParameter( params, 1 );
PA_GetTextParameter( params, 2, regSub );
PA_GetTextParameter( params, 3, regName );
// Convert the 4d registry constant into a Windows registry key.
hRootKey = getRootKey( regKey );
// Open the registry key.
retErr = RegOpenKeyEx(hRootKey, regSub, 0, KEY_READ, &hOpenKey);
if(retErr == ERROR_SUCCESS){
// Get the value type and size.
retErr = RegQueryValueEx(hOpenKey, regName, NULL, &dwDataType, NULL, &dataSize);
if(retErr == ERROR_SUCCESS){
switch(dwDataType){
case REG_BINARY:
returnDataBuffer = malloc(dataSize);
retErr = RegQueryValueEx(hOpenKey, regName, NULL, NULL, (LPBYTE) returnDataBuffer, &dataSize);
if(retErr == ERROR_SUCCESS){
PA_SetBlobParameter(params, 4, returnDataBuffer, dataSize);
returnValue = 1;
}
free(returnDataBuffer);
break;
case REG_DWORD:
case REG_DWORD_BIG_ENDIAN:
dataSize = sizeof(dwReturnLong);
retErr = RegQueryValueEx(hOpenKey, regName, NULL, NULL, (LPBYTE) &dwReturnLong, &dataSize);
if(retErr == ERROR_SUCCESS){
PA_SetLongParameter(params, 4, dwReturnLong);
returnValue = 1;
}
break;
case REG_EXPAND_SZ:
returnDataBuffer = malloc(dataSize);
retErr = RegQueryValueEx (hOpenKey, regName, NULL, NULL, returnDataBuffer, &dataSize);
if(retErr == ERROR_SUCCESS)
{
regExpandStr(&returnDataBuffer);
PA_SetTextParameter(params, 4, returnDataBuffer, strlen(returnDataBuffer));
returnValue = 1;
}
free(returnDataBuffer);
break;
case REG_MULTI_SZ:
returnDataBuffer = malloc(dataSize);
paReturnArray = PA_GetVariableParameter( params, 4 );
retErr = RegQueryValueEx(hOpenKey, regName, NULL, NULL, returnDataBuffer, &dataSize);
if(retErr == ERROR_SUCCESS)
{
arraySize = regGetNumElements(returnDataBuffer);
PA_ResizeArray(&paReturnArray, arraySize);
for(i = 1, ptrData = returnDataBuffer; i <= arraySize; i++)
//.........这里部分代码省略.........
示例4: cm_DaemonCheckInit
void
cm_DaemonCheckInit(void)
{
HKEY parmKey;
DWORD dummyLen;
DWORD dummy;
DWORD code;
code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
0, KEY_QUERY_VALUE, &parmKey);
if (code)
return;
dummyLen = sizeof(DWORD);
code = RegQueryValueEx(parmKey, "daemonCheckDownInterval", NULL, NULL,
(BYTE *) &dummy, &dummyLen);
if (code == ERROR_SUCCESS && dummy)
cm_daemonCheckDownInterval = dummy;
afsi_log("daemonCheckDownInterval is %d", cm_daemonCheckDownInterval);
dummyLen = sizeof(DWORD);
code = RegQueryValueEx(parmKey, "daemonCheckUpInterval", NULL, NULL,
(BYTE *) &dummy, &dummyLen);
if (code == ERROR_SUCCESS && dummy)
cm_daemonCheckUpInterval = dummy;
afsi_log("daemonCheckUpInterval is %d", cm_daemonCheckUpInterval);
dummyLen = sizeof(DWORD);
code = RegQueryValueEx(parmKey, "daemonCheckVolInterval", NULL, NULL,
(BYTE *) &dummy, &dummyLen);
if (code == ERROR_SUCCESS && dummy)
cm_daemonCheckVolInterval = dummy;
afsi_log("daemonCheckVolInterval is %d", cm_daemonCheckVolInterval);
dummyLen = sizeof(DWORD);
code = RegQueryValueEx(parmKey, "daemonCheckCBInterval", NULL, NULL,
(BYTE *) &dummy, &dummyLen);
if (code == ERROR_SUCCESS && dummy)
cm_daemonCheckCBInterval = dummy;
afsi_log("daemonCheckCBInterval is %d", cm_daemonCheckCBInterval);
dummyLen = sizeof(DWORD);
code = RegQueryValueEx(parmKey, "daemonCheckVolCBInterval", NULL, NULL,
(BYTE *) &dummy, &dummyLen);
if (code == ERROR_SUCCESS && dummy)
cm_daemonCheckVolCBInterval = dummy;
afsi_log("daemonCheckVolCBInterval is %d", cm_daemonCheckVolCBInterval);
dummyLen = sizeof(DWORD);
code = RegQueryValueEx(parmKey, "daemonCheckLockInterval", NULL, NULL,
(BYTE *) &dummy, &dummyLen);
if (code == ERROR_SUCCESS && dummy)
cm_daemonCheckLockInterval = dummy;
afsi_log("daemonCheckLockInterval is %d", cm_daemonCheckLockInterval);
dummyLen = sizeof(DWORD);
code = RegQueryValueEx(parmKey, "daemonCheckTokenInterval", NULL, NULL,
(BYTE *) &dummy, &dummyLen);
if (code == ERROR_SUCCESS && dummy)
cm_daemonTokenCheckInterval = dummy;
afsi_log("daemonCheckTokenInterval is %d", cm_daemonTokenCheckInterval);
dummyLen = sizeof(DWORD);
code = RegQueryValueEx(parmKey, "daemonCheckOfflineVolInterval", NULL, NULL,
(BYTE *) &dummy, &dummyLen);
if (code == ERROR_SUCCESS && dummy)
cm_daemonCheckOfflineVolInterval = dummy;
afsi_log("daemonCheckOfflineVolInterval is %d", cm_daemonCheckOfflineVolInterval);
dummyLen = sizeof(DWORD);
code = RegQueryValueEx(parmKey, "daemonPerformanceTuningInterval", NULL, NULL,
(BYTE *) &dummy, &dummyLen);
dummyLen = sizeof(DWORD);
code = RegQueryValueEx(parmKey, "daemonRankServerInterval", NULL, NULL,
(BYTE *) &dummy, &dummyLen);
if (code == ERROR_SUCCESS && dummy)
cm_daemonRankServerInterval = dummy;
afsi_log("daemonRankServerInterval is %d", cm_daemonRankServerInterval);
if (code == ERROR_SUCCESS)
cm_daemonPerformanceTuningInterval = dummy;
afsi_log("daemonPerformanceTuningInterval is %d", cm_daemonPerformanceTuningInterval);
RegCloseKey(parmKey);
if (cm_daemonPerformanceTuningInterval)
cm_PerformanceTuningInit();
}
示例5: DirSelectProc
BOOL CALLBACK DirSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_INITDIALOG:
{
HKEY hKeyResults = 0;
char String[256];
char Directory[255];
long lResult;
sprintf(String,"Software\\N64 Emulation\\%s",AppName);
lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0, KEY_ALL_ACCESS,&hKeyResults);
if (lResult == ERROR_SUCCESS) {
DWORD Type, Value, Bytes = 4;
lResult = RegQueryValueEx(hKeyResults,"Use Default Plugin Dir",0,&Type,(LPBYTE)(&Value),&Bytes);
if (Type != REG_DWORD || lResult != ERROR_SUCCESS) { Value = TRUE; }
SendMessage(GetDlgItem(hDlg,Value?IDC_PLUGIN_DEFAULT:IDC_PLUGIN_OTHER),BM_SETCHECK, BST_CHECKED,0);
lResult = RegQueryValueEx(hKeyResults,"Use Default Rom Dir",0,&Type,(LPBYTE)(&Value),&Bytes);
if (Type != REG_DWORD || lResult != ERROR_SUCCESS) { Value = FALSE; }
SendMessage(GetDlgItem(hDlg,Value?IDC_ROM_DEFAULT:IDC_ROM_OTHER),BM_SETCHECK, BST_CHECKED,0);
lResult = RegQueryValueEx(hKeyResults,"Use Default Auto Save Dir",0,&Type,(LPBYTE)(&Value),&Bytes);
if (Type != REG_DWORD || lResult != ERROR_SUCCESS) { Value = TRUE; }
SendMessage(GetDlgItem(hDlg,Value?IDC_AUTO_DEFAULT:IDC_AUTO_OTHER),BM_SETCHECK, BST_CHECKED,0);
lResult = RegQueryValueEx(hKeyResults,"Use Default Instant Save Dir",0,&Type,(LPBYTE)(&Value),&Bytes);
if (Type != REG_DWORD || lResult != ERROR_SUCCESS) { Value = TRUE; }
SendMessage(GetDlgItem(hDlg,Value?IDC_INSTANT_DEFAULT:IDC_INSTANT_OTHER),BM_SETCHECK, BST_CHECKED,0);
lResult = RegQueryValueEx(hKeyResults,"Use Default Snap Shot Dir",0,&Type,(LPBYTE)(&Value),&Bytes);
if (Type != REG_DWORD || lResult != ERROR_SUCCESS) { Value = TRUE; }
SendMessage(GetDlgItem(hDlg,Value?IDC_SNAP_DEFAULT:IDC_SNAP_OTHER),BM_SETCHECK, BST_CHECKED,0);
Bytes = sizeof(Directory);
lResult = RegQueryValueEx(hKeyResults,"Plugin Directory",0,&Type,(LPBYTE)Directory,&Bytes);
if (lResult != ERROR_SUCCESS) { GetPluginDir(Directory ); }
SetDlgItemText(hDlg,IDC_PLUGIN_DIR,Directory);
Bytes = sizeof(Directory);
lResult = RegQueryValueEx(hKeyResults,"Instant Save Directory",0,&Type,(LPBYTE)Directory,&Bytes);
if (lResult != ERROR_SUCCESS) { GetInstantSaveDir(Directory); }
SetDlgItemText(hDlg,IDC_INSTANT_DIR,Directory);
Bytes = sizeof(Directory);
lResult = RegQueryValueEx(hKeyResults,"Auto Save Directory",0,&Type,(LPBYTE)Directory,&Bytes);
if (lResult != ERROR_SUCCESS) { GetAutoSaveDir(Directory); }
SetDlgItemText(hDlg,IDC_AUTO_DIR,Directory);
Bytes = sizeof(Directory);
lResult = RegQueryValueEx(hKeyResults,"Snap Shot Directory",0,&Type,(LPBYTE)Directory,&Bytes);
if (lResult != ERROR_SUCCESS) { GetSnapShotDir(Directory); }
SetDlgItemText(hDlg,IDC_SNAP_DIR,Directory);
} else {
SendMessage(GetDlgItem(hDlg,IDC_PLUGIN_DEFAULT),BM_SETCHECK, BST_CHECKED,0);
SendMessage(GetDlgItem(hDlg,IDC_ROM_DEFAULT),BM_SETCHECK, BST_CHECKED,0);
SendMessage(GetDlgItem(hDlg,IDC_AUTO_DEFAULT),BM_SETCHECK, BST_CHECKED,0);
SendMessage(GetDlgItem(hDlg,IDC_INSTANT_DEFAULT),BM_SETCHECK, BST_CHECKED,0);
SendMessage(GetDlgItem(hDlg,IDC_SNAP_DEFAULT),BM_SETCHECK, BST_CHECKED,0);
GetPluginDir(Directory );
SetDlgItemText(hDlg,IDC_PLUGIN_DIR,Directory);
GetInstantSaveDir(Directory);
SetDlgItemText(hDlg,IDC_INSTANT_DIR,Directory);
GetAutoSaveDir(Directory);
SetDlgItemText(hDlg,IDC_AUTO_DIR,Directory);
GetSnapShotDir(Directory);
SetDlgItemText(hDlg,IDC_SNAP_DIR,Directory);
}
GetRomDirectory( Directory );
SetDlgItemText(hDlg,IDC_ROM_DIR,Directory);
SetDlgItemText(hDlg,IDC_DIR_FRAME1,GS(DIR_PLUGIN));
SetDlgItemText(hDlg,IDC_DIR_FRAME2,GS(DIR_ROM));
SetDlgItemText(hDlg,IDC_DIR_FRAME3,GS(DIR_AUTO_SAVE));
SetDlgItemText(hDlg,IDC_DIR_FRAME4,GS(DIR_INSTANT_SAVE));
SetDlgItemText(hDlg,IDC_DIR_FRAME5,GS(DIR_SCREEN_SHOT));
SetDlgItemText(hDlg,IDC_ROM_DEFAULT,GS(DIR_ROM_DEFAULT));
}
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_SELECT_PLUGIN_DIR:
case IDC_SELECT_ROM_DIR:
case IDC_SELECT_INSTANT_DIR:
case IDC_SELECT_AUTO_DIR:
case IDC_SELECT_SNAP_DIR:
{
char Buffer[MAX_PATH], Directory[255], Title[255];
LPITEMIDLIST pidl;
BROWSEINFO bi;
switch (LOWORD(wParam)) {
case IDC_SELECT_PLUGIN_DIR:
strcpy(Title,GS(DIR_SELECT_PLUGIN));
GetPluginDir(Directory);
break;
case IDC_SELECT_ROM_DIR:
GetRomDirectory(Directory);
strcpy(Title,GS(DIR_SELECT_ROM));
break;
//.........这里部分代码省略.........
示例6: nla_new
rdpNla* nla_new(freerdp* instance, rdpTransport* transport, rdpSettings* settings)
{
rdpNla* nla = (rdpNla*) calloc(1, sizeof(rdpNla));
if (!nla)
return NULL;
nla->identity = calloc(1, sizeof(SEC_WINNT_AUTH_IDENTITY));
if (!nla->identity)
{
free (nla);
return NULL;
}
nla->instance = instance;
nla->settings = settings;
nla->server = settings->ServerMode;
nla->transport = transport;
nla->sendSeqNum = 0;
nla->recvSeqNum = 0;
nla->version = 3;
ZeroMemory(&nla->negoToken, sizeof(SecBuffer));
ZeroMemory(&nla->pubKeyAuth, sizeof(SecBuffer));
ZeroMemory(&nla->authInfo, sizeof(SecBuffer));
SecInvalidateHandle(&nla->context);
if (nla->server)
{
LONG status;
HKEY hKey;
DWORD dwType;
DWORD dwSize;
status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, SERVER_KEY,
0, KEY_READ | KEY_WOW64_64KEY, &hKey);
if (status != ERROR_SUCCESS)
return nla;
status = RegQueryValueEx(hKey, _T("SspiModule"), NULL, &dwType, NULL, &dwSize);
if (status != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return nla;
}
nla->SspiModule = (LPTSTR) malloc(dwSize + sizeof(TCHAR));
if (!nla->SspiModule)
{
RegCloseKey(hKey);
free(nla);
return NULL;
}
status = RegQueryValueEx(hKey, _T("SspiModule"), NULL, &dwType,
(BYTE*) nla->SspiModule, &dwSize);
if (status == ERROR_SUCCESS)
WLog_INFO(TAG, "Using SSPI Module: %s", nla->SspiModule);
RegCloseKey(hKey);
}
return nla;
}
示例7: toWideChar
/*
* Returns the value of the given property
* the value is returned as a new char array and must be free'd by the user
*
* @param property - the property name
*/
char* DeviceManagementNode::readPropertyValue(const char* prop) {
HKEY key = NULL;
DWORD res;
long err = 0;
char *ret=NULL;
TCHAR *p = toWideChar(prop);
ULONG dim = 0;
RegCreateKeyEx(
HKEY_DM_ROOT,
fullContext,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&key,
&res
);
if (key == 0) {
//lastErrorCode = ERR_INVALID_CONTEXT;
//sprintf(lastErrorMsg, "Invalid context path: %ls", fullContext);
setErrorF(ERR_INVALID_CONTEXT, "Invalid context path: %ls", fullContext);
goto finally;
}
// Get value length
err = RegQueryValueEx(
key,
p,
NULL,
NULL, // we currently support only strings
NULL,
&dim
);
if (err == ERROR_SUCCESS) {
if (dim > 0) {
TCHAR *buf = new TCHAR[dim + 1];
err = RegQueryValueEx(
key,
p,
NULL,
NULL, // we currently support only strings
(UCHAR*)buf,
&dim
);
if (err == ERROR_SUCCESS)
ret = toMultibyte(buf);
delete [] buf;
}
}
//else MessageBox(NULL, "Error", "getConfigParameter", MB_OK);
if (!ret)
ret = stringdup("");
finally:
if (p)
delete [] p;
if (key != 0) {
RegCloseKey(key);
}
return ret;
}
示例8: mMajorVer
LLOSInfo::LLOSInfo() :
mMajorVer(0), mMinorVer(0), mBuild(0)
{
#if LL_WINDOWS
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx;
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if(!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) &osvi)))
{
// If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if(!GetVersionEx( (OSVERSIONINFO *) &osvi))
return;
}
mMajorVer = osvi.dwMajorVersion;
mMinorVer = osvi.dwMinorVersion;
mBuild = osvi.dwBuildNumber;
switch(osvi.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT:
{
// Test for the product.
if(osvi.dwMajorVersion <= 4)
{
mOSStringSimple = "Microsoft Windows NT ";
}
else if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
{
mOSStringSimple = "Microsoft Windows 2000 ";
}
else if(osvi.dwMajorVersion ==5 && osvi.dwMinorVersion == 1)
{
mOSStringSimple = "Microsoft Windows XP ";
}
else if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
{
if(osvi.wProductType == VER_NT_WORKSTATION)
mOSStringSimple = "Microsoft Windows XP x64 Edition ";
else
mOSStringSimple = "Microsoft Windows Server 2003 ";
}
else if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0)
{
if(osvi.wProductType == VER_NT_WORKSTATION)
mOSStringSimple = "Microsoft Windows Vista ";
else mOSStringSimple = "Microsoft Windows Vista Server ";
}
else // Use the registry on early versions of Windows NT.
{
HKEY hKey;
WCHAR szProductType[80];
DWORD dwBufLen;
RegOpenKeyEx( HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
0, KEY_QUERY_VALUE, &hKey );
RegQueryValueEx( hKey, L"ProductType", NULL, NULL,
(LPBYTE) szProductType, &dwBufLen);
RegCloseKey( hKey );
if ( lstrcmpi( L"WINNT", szProductType) == 0 )
{
mOSStringSimple += "Professional ";
}
else if ( lstrcmpi( L"LANMANNT", szProductType) == 0 )
{
mOSStringSimple += "Server ";
}
else if ( lstrcmpi( L"SERVERNT", szProductType) == 0 )
{
mOSStringSimple += "Advanced Server ";
}
}
std::string csdversion = utf16str_to_utf8str(osvi.szCSDVersion);
// Display version, service pack (if any), and build number.
std::string tmpstr;
if(osvi.dwMajorVersion <= 4)
{
tmpstr = llformat("version %d.%d %s (Build %d)",
osvi.dwMajorVersion,
osvi.dwMinorVersion,
csdversion.c_str(),
(osvi.dwBuildNumber & 0xffff));
}
else
{
tmpstr = llformat("%s (Build %d)",
csdversion.c_str(),
(osvi.dwBuildNumber & 0xffff));
}
mOSString = mOSStringSimple + tmpstr;
}
break;
case VER_PLATFORM_WIN32_WINDOWS:
// Test for the Windows 95 product family.
//.........这里部分代码省略.........
示例9: GetSpecialFolder
static sal_Bool GetSpecialFolder(rtl_uString **strPath, int nFolder)
{
sal_Bool bRet = sal_False;
HINSTANCE hLibrary;
sal_Char PathA[_MAX_PATH];
sal_Unicode PathW[_MAX_PATH];
if ((hLibrary = LoadLibrary("shell32.dll")) != NULL)
{
BOOL (WINAPI *pSHGetSpecialFolderPathA)(HWND, LPSTR, int, BOOL);
BOOL (WINAPI *pSHGetSpecialFolderPathW)(HWND, LPWSTR, int, BOOL);
pSHGetSpecialFolderPathA = (BOOL (WINAPI *)(HWND, LPSTR, int, BOOL))GetProcAddress(hLibrary, "SHGetSpecialFolderPathA");
pSHGetSpecialFolderPathW = (BOOL (WINAPI *)(HWND, LPWSTR, int, BOOL))GetProcAddress(hLibrary, "SHGetSpecialFolderPathW");
if (pSHGetSpecialFolderPathA)
{
if (pSHGetSpecialFolderPathA(GetActiveWindow(), PathA, nFolder, TRUE))
{
rtl_string2UString( strPath, PathA, strlen(PathA), osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS);
OSL_ASSERT(*strPath != NULL);
bRet = sal_True;
}
}
else if (pSHGetSpecialFolderPathW)
{
if (pSHGetSpecialFolderPathW(GetActiveWindow(), PathW, nFolder, TRUE))
{
rtl_uString_newFromStr( strPath, PathW);
bRet = sal_True;
}
}
else
{
HRESULT (WINAPI *pSHGetSpecialFolderLocation)(HWND, int, LPITEMIDLIST *) = (HRESULT (WINAPI *)(HWND, int, LPITEMIDLIST *))GetProcAddress(hLibrary, "SHGetSpecialFolderLocation");
BOOL (WINAPI *pSHGetPathFromIDListA)(LPCITEMIDLIST, LPSTR) = (BOOL (WINAPI *)(LPCITEMIDLIST, LPSTR))GetProcAddress(hLibrary, "SHGetPathFromIDListA");
BOOL (WINAPI *pSHGetPathFromIDListW)(LPCITEMIDLIST, LPWSTR) = (BOOL (WINAPI *)(LPCITEMIDLIST, LPWSTR))GetProcAddress(hLibrary, "SHGetPathFromIDListW");
HRESULT (WINAPI *pSHGetMalloc)(LPMALLOC *) = (HRESULT (WINAPI *)(LPMALLOC *))GetProcAddress(hLibrary, "SHGetMalloc");
if (pSHGetSpecialFolderLocation && (pSHGetPathFromIDListA || pSHGetPathFromIDListW ) && pSHGetMalloc )
{
LPITEMIDLIST pidl;
LPMALLOC pMalloc;
HRESULT hr;
hr = pSHGetSpecialFolderLocation(GetActiveWindow(), nFolder, &pidl);
/* Get SHGetSpecialFolderLocation fails if directory does not exists. */
/* If it fails we try to create the directory and redo the call */
if (! SUCCEEDED(hr))
{
HKEY hRegKey;
if (RegOpenKey(HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
&hRegKey) == ERROR_SUCCESS)
{
LONG lRet;
DWORD lSize = elementsof(PathA);
DWORD Type = REG_SZ;
switch (nFolder)
{
case CSIDL_APPDATA:
lRet = RegQueryValueEx(hRegKey, "AppData", NULL, &Type, (LPBYTE)PathA, &lSize);
break;
case CSIDL_PERSONAL:
lRet = RegQueryValueEx(hRegKey, "Personal", NULL, &Type, (LPBYTE)PathA, &lSize);
break;
default:
lRet = -1l;
}
if ((lRet == ERROR_SUCCESS) && (Type == REG_SZ))
{
if (_access(PathA, 0) < 0)
CreateDirectory(PathA, NULL);
hr = pSHGetSpecialFolderLocation(GetActiveWindow(), nFolder, &pidl);
}
RegCloseKey(hRegKey);
}
}
if (SUCCEEDED(hr))
{
if (pSHGetPathFromIDListW && pSHGetPathFromIDListW(pidl, PathW))
{
/* if directory does not exist, create it */
if (_waccess(PathW, 0) < 0)
CreateDirectoryW(PathW, NULL);
rtl_uString_newFromStr( strPath, PathW);
bRet = sal_True;
}
else if (pSHGetPathFromIDListA && pSHGetPathFromIDListA(pidl, PathA))
//.........这里部分代码省略.........
示例10: NetworkDownloadThreadProc
//.........这里部分代码省略.........
{
fullpath += ext;
}
} while (PathFileExists(fullpath.c_str()));
}
// Create empty file
HANDLE hFile = CreateFile(fullpath.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile);
LeaveCriticalSection(&g_CriticalSection);
}
if (ready)
{
// Delete IE cache before download if "SyncMode5" is not 3 (every visit to the page)
{
// Check "Temporary Internet Files" sync mode (SyncMode5)
// Values:
// Every visit to the page 3
// Every time you start Internet Explorer 2
// Automatically (default) 4
// Never 0
// http://support.microsoft.com/kb/263070/en
HKEY hKey;
LONG ret;
DWORD mode;
ret = RegOpenKeyEx(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", 0, KEY_QUERY_VALUE, &hKey);
if (ret == ERROR_SUCCESS)
{
DWORD size = sizeof(mode);
ret = RegQueryValueEx(hKey, L"SyncMode5", nullptr, nullptr, (LPBYTE)&mode, &size);
RegCloseKey(hKey);
}
if (ret != ERROR_SUCCESS || mode != 3)
{
std::wstring::size_type pos = url.find_first_of(L'#');
if (pos != std::wstring::npos)
{
DeleteUrlCacheEntry(url.substr(0, pos).c_str());
}
else
{
DeleteUrlCacheEntry(url.c_str());
}
}
}
// Write some log info
std::wstring log = L"WebParser.dll: [";
log += measure->section;
log += L"] Downloading url ";
log += url;
log += L" to ";
log += fullpath;
RmLog(LOG_DEBUG, log.c_str());
HRESULT resultCoInitialize = CoInitialize(nullptr); // requires before calling URLDownloadToFile function
// Download the file
HRESULT result = URLDownloadToFile(nullptr, url.c_str(), fullpath.c_str(), 0, nullptr);
if (result == S_OK)
示例11: GetNewFspRegistryData
BOOL
GetNewFspRegistryData(
BOOL *bLoggingEnabled,
LPWSTR lpszLoggingDirectory,
DWORD dwLoggingDirectoryBufferSize,
PDEVICE_INFO *pDeviceInfo,
LPDWORD pdwNumDevices
)
{
// hServiceProvidersKey is the handle to the fax service providers registry key
HKEY hServiceProvidersKey = NULL;
// hNewFspKey is the handle to the newfsp service provider registry key
HKEY hNewFspKey = NULL;
// hDevicesKey is the handle to the virtual fax devices registry key
HKEY hDevicesKey = NULL;
// dwSubkeys is the number of virtual fax device registry subkeys
DWORD dwSubkeys;
// dwIndex is a counter to enumerate each virtual fax device registry subkey
DWORD dwIndex;
// szDeviceSubkey is the name of a virtual fax device registry subkey
WCHAR szDeviceSubkey[MAX_PATH] ={0};
// hDeviceSubkey is the handle to a virtual fax device registry subkey
HKEY hDeviceSubkey = NULL;
DWORD dwType;
// pCurrentDeviceInfo is a pointer to the current virtual fax device
PDEVICE_INFO pCurrentDeviceInfo = NULL;
DWORD dwLoggingEnabledSize;
DWORD dwLoggingDirectorySize = dwLoggingDirectoryBufferSize - 1;
DWORD dwDirectorySize;
HRESULT hr = S_OK;
BOOL bRetVal = FALSE;
if (bLoggingEnabled != NULL) {
*bLoggingEnabled = FALSE;
}
if (pDeviceInfo != NULL) {
*pDeviceInfo = NULL;
}
if (pdwNumDevices != NULL) {
*pdwNumDevices = 0;
}
// Open the fax service providers registry key
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
FAX_PROVIDERS_REGKEY,
0,
KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,
&hServiceProvidersKey) != ERROR_SUCCESS) {
goto Exit;
}
// Open the newfsp service provider registry key
if (RegOpenKeyEx(hServiceProvidersKey,
NEWFSP_PROVIDER,
0,
KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,
&hNewFspKey) != ERROR_SUCCESS) {
goto Exit;
}
if (bLoggingEnabled != NULL) {
// Get the logging enabled
dwLoggingEnabledSize = sizeof(BOOL);
RegQueryValueEx(hNewFspKey,
NEWFSP_LOGGING_ENABLED,
NULL,
&dwType,
(LPBYTE) bLoggingEnabled,
&dwLoggingEnabledSize);
}
if (lpszLoggingDirectory != NULL) {
// Get the logging directory
if ((RegQueryValueEx(hNewFspKey,
NEWFSP_LOGGING_DIRECTORY,
NULL,
&dwType,
(LPBYTE) lpszLoggingDirectory,
&dwLoggingDirectorySize) != ERROR_SUCCESS)||
(dwLoggingDirectorySize >= MAX_PATH)){
goto Exit;
}
}
if ((pDeviceInfo != NULL) || (pdwNumDevices != NULL)) {
// Open the virtual fax devices registry key
if (RegOpenKeyEx(hNewFspKey,
NEWFSP_DEVICES,
0,
KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS,
&hDevicesKey) != ERROR_SUCCESS) {
goto Exit;
}
// Determine the number of virtual fax device registry subkeys
//.........这里部分代码省略.........
示例12: RegOpenKeyEx
bool CShellUpdater::RebuildIcons()
{
const int BUFFER_SIZE = 1024;
TCHAR buf[BUFFER_SIZE] = { 0 };
HKEY hRegKey = nullptr;
DWORD dwRegValue;
DWORD dwRegValueTemp;
DWORD dwSize;
DWORD_PTR dwResult;
LONG lRegResult;
lRegResult = RegOpenKeyEx(HKEY_CURRENT_USER, L"Control Panel\\Desktop\\WindowMetrics",
0, KEY_READ | KEY_WRITE, &hRegKey);
if (lRegResult != ERROR_SUCCESS)
return false;
SCOPE_EXIT { RegCloseKey(hRegKey); };
// we're going to change the Shell Icon Size value
const TCHAR* sRegValueName = L"Shell Icon Size";
// Read registry value
dwSize = BUFFER_SIZE;
lRegResult = RegQueryValueEx(hRegKey, sRegValueName, nullptr, nullptr,
(LPBYTE) buf, &dwSize);
if (lRegResult != ERROR_FILE_NOT_FOUND)
{
// If registry key doesn't exist create it using system current setting
int iDefaultIconSize = ::GetSystemMetrics(SM_CXICON);
if (0 == iDefaultIconSize)
iDefaultIconSize = 32;
_sntprintf_s(buf, BUFFER_SIZE, BUFFER_SIZE, L"%d", iDefaultIconSize);
}
else if (lRegResult != ERROR_SUCCESS)
return false;
// Change registry value
dwRegValue = _wtoi(buf);
dwRegValueTemp = dwRegValue-1;
dwSize = _sntprintf_s(buf, BUFFER_SIZE, BUFFER_SIZE, L"%lu", dwRegValueTemp) + sizeof(TCHAR);
lRegResult = RegSetValueEx(hRegKey, sRegValueName, 0, REG_SZ,
(LPBYTE) buf, dwSize);
if (lRegResult != ERROR_SUCCESS)
return false;
// Update all windows
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS,
0, SMTO_ABORTIFHUNG, 5000, &dwResult);
// Reset registry value
dwSize = _sntprintf_s(buf, BUFFER_SIZE, BUFFER_SIZE, L"%lu", dwRegValue) + sizeof(TCHAR);
lRegResult = RegSetValueEx(hRegKey, sRegValueName, 0, REG_SZ,
(LPBYTE) buf, dwSize);
if (lRegResult != ERROR_SUCCESS)
return false;
// Update all windows
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS,
0, SMTO_ABORTIFHUNG, 5000, &dwResult);
return true;
}
示例13: AssociateTo
void AssociateTo(char* Ext, bool SetOpen)
{
try
{
HKEY Key;
DWORD Size = MAX_PATH;
/* Open or create the key for this extension */
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, Ext, 0, KEY_ALL_ACCESS, &Key) != ERROR_SUCCESS)
RegCreateKey(HKEY_CLASSES_ROOT, Ext, &Key);
else
{
/* Get or set the key associated to this extension */
char* Value = new char[Size];
if (RegQueryValueEx(Key, NULL, NULL, NULL, (BYTE*)Value, &Size) != ERROR_SUCCESS)
{
strcpy(Value, "LambdaDocument");
RegSetValueEx(Key, NULL, 0, REG_SZ, (BYTE*)Value, strlen(Value)+1);
RegCloseKey(Key);
}
/* Open or create the key associated to this extension */
if (RegOpenKeyEx(HKEY_CLASSES_ROOT, Value, 0, KEY_ALL_ACCESS, &Key) != ERROR_SUCCESS)
{
RegCreateKey(HKEY_CLASSES_ROOT, Value, &Key);
RegCloseKey(Key);
}
/* Set the icon associated to this extension */
if (SetOpen)
{
char* Str = new char[MAX_PATH];
strcpy(Str, Value);
strcat(Str, "\\DefaultIcon");
if (RegOpenKey(HKEY_CLASSES_ROOT, Str, &Key) == ERROR_SUCCESS)
{
char* FileName = new char[MAX_PATH];
GetModuleFileName(hInstance, FileName, MAX_PATH);
strcat(FileName, ",1");
RegSetValueEx(Key, "", 0, REG_SZ, (BYTE*)FileName, strlen(FileName)+1);
RegCloseKey(Key);
delete[] FileName;
}
delete[] Str;
}
/* Set the command */
if (SetOpen)
strcat(Value, "\\shell\\open\\command");
else
strcat(Value, "\\shell\\edit\\command");
if (RegOpenKey(HKEY_CLASSES_ROOT, Value, &Key) == ERROR_SUCCESS)
{
char* FileName = new char[MAX_PATH];
GetModuleFileName(hInstance, FileName, MAX_PATH);
strcat(FileName, " \"%1\"");
RegSetValueEx(Key, NULL, 0, REG_SZ, (BYTE*)FileName, strlen(FileName)+1);
RegCloseKey(Key);
delete[] FileName;
}
delete[] Value;
}
}
catch (exception e)
{
}
}
示例14: _WriteDlgString
BOOL CWebFileOpenDlg::OnInitDialog()
{
#ifdef _WRITE_LNG_FILE_
_WriteDlgString(this,"DialogOpenFile");
this->OnCancel();
return TRUE;
#endif
LOADDLG("DialogOpenFile");
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CImageList img;
img.Create(16, 16, ILC_COLORDDB|ILC_MASK, 2, 1);
HBITMAP hbmp = pmf->GetBitmap("FavBar.bmp");
ImageList_AddMasked(img.GetSafeHandle(), hbmp, RGB(255,0,255));
DeleteObject(hbmp);
m_conAddress.SetImageList(&img);
img.Detach();
m_conAddress.SetExtendedStyle(0, m_conAddress.GetExtendedStyle()|CBES_EX_NOSIZELIMIT);
//auto complete
HINSTANCE hIns = LoadLibrary("shlwapi.dll");
if(hIns != NULL)
{
LPFNDLLFUNC1 lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hIns, "SHAutoComplete");
if(lpfnDllFunc1!=NULL)
lpfnDllFunc1(m_conAddress.GetEditCtrl()->m_hWnd, 0xe);
FreeLibrary(hIns);
}
//typed urls
TCHAR sz[MAX_PATH];
HKEY hKey;
DWORD dwSize;
TCHAR id[9] = "url";
int i = 1;
if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\TypedUrls"), &hKey) != ERROR_SUCCESS)
{
TRACE0("Typed URLs not found\n");
return TRUE;
}
dwSize = MAX_PATH-1;
itoa(i, id+3, 10);
COMBOBOXEXITEM item;
item.mask = CBEIF_TEXT|CBEIF_IMAGE|CBEIF_SELECTEDIMAGE ;
item.iImage = 1;
item.iSelectedImage = 1;
dwSize = sizeof(sz);
while(RegQueryValueEx(hKey, _T(id), NULL, NULL, (LPBYTE)sz, &dwSize) == ERROR_SUCCESS)
{
item.iItem = i-1;
item.pszText = (LPTSTR)(LPCTSTR)sz;
m_conAddress.InsertItem(&item);
i++;
itoa(i, id+3, 10);
dwSize = MAX_PATH - 1;
}
RegCloseKey(hKey);
if (m_bDirectOpenFile)
{
OnBrowse();
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例15: _tWinMain
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
TCHAR *cmdline;
TCHAR seekchar = _T(' ');
cmdline = GetCommandLine();
if (*cmdline == _T('\"'))
seekchar = *cmdline++;
while (*cmdline && *cmdline != seekchar)
cmdline = CharNext(cmdline);
cmdline = CharNext(cmdline);
while (*cmdline == _T(' '))
cmdline++;
if (*cmdline++ != _T('/'))
{
ExitProcess(1);
return 0;
}
if (*cmdline == _T('S'))
{
HKEY rootkey;
TCHAR *keyname, *file; // These are turned into heap memory to avoid _chkstk
keyname = (TCHAR*) GlobalAlloc(GPTR, STR_SIZE*sizeof(TCHAR));
file = (TCHAR*) GlobalAlloc(GPTR, STR_SIZE*sizeof(TCHAR));
if (SUCCEEDED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\NSIS.Library.RegTool.v3"), 0, KEY_READ, &rootkey)))
{
while (RegEnumKey(rootkey, 0, keyname, STR_SIZE) == ERROR_SUCCESS)
{
HKEY key;
if (SUCCEEDED(RegOpenKeyEx(rootkey, keyname, 0, KEY_READ, &key)))
{
DWORD t, count, l = sizeof(DWORD);
if (SUCCEEDED(RegQueryValueEx(key, _T("count"), NULL, &t, (LPBYTE) &count, &l)) && t == REG_DWORD)
{
DWORD j;
TCHAR valname[128], mode[3];
for (j = 1; j <= count; j++)
{
wsprintf(valname, _T("%u.mode"), j);
l = sizeof(mode);
if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) mode, &l)) || t != REG_SZ)
continue;
wsprintf(valname, _T("%u.file"), j);
l = STR_SIZE*sizeof(TCHAR);
if (FAILED(RegQueryValueEx(key, valname, NULL, &t, (LPBYTE) file, &l)) || t != REG_SZ)
continue;
// JP: Note, if this mode[1] is used as anything but a boolean later on,
// we'll need to consider the next line carefully.
RegFile(mode[0], file, mode[1] == 'X');
}
}
RegCloseKey(key);
RegDeleteKey(rootkey, keyname);
}
}
RegCloseKey(rootkey);
RegDeleteKey(HKEY_LOCAL_MACHINE, _T("Software\\NSIS.Library.RegTool.v3"));
}
{
if (GetModuleFileName(GetModuleHandle(NULL), file, STR_SIZE))
{
DeleteFileOnReboot(file);
}
}
GlobalFree(keyname);
GlobalFree(file);
}
else
{
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
OleInitialize(NULL);
if (*cmdline == _T('D'))
{
RegDll(cmdline + 1);
}
else if (*cmdline == _T('T'))
{
RegTypeLib(cmdline + 1);
}
OleUninitialize();
SetErrorMode(0);
}
ExitProcess(0);
return 0;
}