/* A helper function: Allocate and fill rString. Return number of bytes read. */ static DWORD get_profile_string(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpFileName, WCHAR **rString ) { DWORD r = 0; DWORD len = 128; WCHAR *buffer; buffer = CoTaskMemAlloc(len * sizeof(*buffer)); if (buffer != NULL) { r = GetPrivateProfileStringW(lpAppName, lpKeyName, NULL, buffer, len, lpFileName); while (r == len-1) { WCHAR *realloc_buf; len *= 2; realloc_buf = CoTaskMemRealloc(buffer, len * sizeof(*buffer)); if (realloc_buf == NULL) { CoTaskMemFree(buffer); *rString = NULL; return 0; } buffer = realloc_buf; r = GetPrivateProfileStringW(lpAppName, lpKeyName, NULL, buffer, len, lpFileName); } } *rString = buffer; return r; }
void PipeReader::init(wchar_t *section) { wchar_t temp[300]; swprintf(temp,L"SCardSimulatorDriver%i",instance); GetPrivateProfileStringW(section,L"PIPE_NAME",temp,pipeName,300,L"BixVReader.ini"); swprintf(temp,L"SCardSimulatorDriverEvents%i",instance); GetPrivateProfileStringW(section,L"PIPE_EVENT_NAME",temp,pipeEventName,300,L"BixVReader.ini"); }
static HRESULT WINAPI PersistFile_Load(IPersistFile *pFile, LPCOLESTR pszFileName, DWORD dwMode) { WCHAR str_header[] = {'I','n','t','e','r','n','e','t','S','h','o','r','t','c','u','t',0}; WCHAR str_URL[] = {'U','R','L',0}; WCHAR *filename = NULL; HRESULT hr; InternetShortcut *This = impl_from_IPersistFile(pFile); TRACE("(%p, %s, 0x%x)\n", pFile, debugstr_w(pszFileName), dwMode); if (dwMode != 0) FIXME("ignoring unimplemented mode 0x%x\n", dwMode); filename = co_strdupW(pszFileName); if (filename != NULL) { DWORD len = 128; DWORD r; WCHAR *url = CoTaskMemAlloc(len*sizeof(WCHAR)); if (url != NULL) { r = GetPrivateProfileStringW(str_header, str_URL, NULL, url, len, pszFileName); while (r == len-1) { CoTaskMemFree(url); len *= 2; url = CoTaskMemAlloc(len*sizeof(WCHAR)); if (url == NULL) break; r = GetPrivateProfileStringW(str_header, str_URL, NULL, url, len, pszFileName); } if (r == 0) hr = E_FAIL; else if (url != NULL) { CoTaskMemFree(This->currentFile); This->currentFile = filename; CoTaskMemFree(This->url); This->url = url; This->isDirty = FALSE; return S_OK; } else hr = E_OUTOFMEMORY; CoTaskMemFree(url); } else hr = E_OUTOFMEMORY; CoTaskMemFree(filename); } else hr = E_OUTOFMEMORY; return hr; }
static HRESULT install_inf_file(install_ctx_t *ctx) { WCHAR buf[2048], sect_name[128]; BOOL default_install = TRUE; const WCHAR *key; DWORD len; HRESULT hres; static const WCHAR setup_hooksW[] = {'S','e','t','u','p',' ','H','o','o','k','s',0}; static const WCHAR add_codeW[] = {'A','d','d','.','C','o','d','e',0}; len = GetPrivateProfileStringW(setup_hooksW, NULL, NULL, buf, sizeof(buf)/sizeof(*buf), ctx->install_file); if(len) { default_install = FALSE; for(key = buf; *key; key += strlenW(key)+1) { TRACE("[Setup Hooks] key: %s\n", debugstr_w(key)); len = GetPrivateProfileStringW(setup_hooksW, key, NULL, sect_name, sizeof(sect_name)/sizeof(*sect_name), ctx->install_file); if(!len) { WARN("Could not get key value\n"); return E_FAIL; } hres = process_hook_section(ctx, sect_name); if(FAILED(hres)) return hres; } } len = GetPrivateProfileStringW(add_codeW, NULL, NULL, buf, sizeof(buf)/sizeof(*buf), ctx->install_file); if(len) { FIXME("[Add.Code] section not supported\n"); /* Don't throw an error if we successfully ran setup hooks; installation is likely to be complete enough */ if(default_install) return E_NOTIMPL; } if(default_install) { hres = RunSetupCommandW(ctx->hwnd, ctx->install_file, NULL, ctx->tmp_dir, NULL, NULL, RSC_FLAG_INF, NULL); if(FAILED(hres)) { WARN("RunSetupCommandW failed: %08x\n", hres); return hres; } } return S_OK; }
void CConfigFileHandler::ReadFromCfgFileForAll( CString& HexFileName, CString& FlashMethod, CString& DeviceID, CString& COMPORT, CString& BD, CString& IP, CString& IPPort, CString& subnote, CString& subID) { //ASSERT(m_pFile); //ReadFromCfgFile(); GetPrivateProfileStringW(m_ISPTool_Section,CString(c_strCfgLastFlashFileItem),L"",HexFileName.GetBuffer(MAX_PATH),MAX_PATH,m_configfile_path); HexFileName.ReleaseBuffer(); GetPrivateProfileStringW(m_ISPTool_Section,CString(c_strCfgLastFlashMethodItem),L"",FlashMethod.GetBuffer(MAX_PATH),MAX_PATH,m_configfile_path); FlashMethod.ReleaseBuffer(); GetPrivateProfileStringW(m_ISPTool_Section,CString(c_strCfgDefaultAddrItem),L"",DeviceID.GetBuffer(MAX_PATH),MAX_PATH,m_configfile_path); DeviceID.ReleaseBuffer(); GetPrivateProfileStringW(m_ISPTool_Section,CString(c_strCfgDefaultComItem),L"",COMPORT.GetBuffer(MAX_PATH),MAX_PATH,m_configfile_path); COMPORT.ReleaseBuffer(); GetPrivateProfileStringW(m_ISPTool_Section,CString(c_strCfgDefaultIPItem),L"",IP.GetBuffer(MAX_PATH),MAX_PATH,m_configfile_path); IP.ReleaseBuffer(); GetPrivateProfileStringW(m_ISPTool_Section,CString(c_strCfgDefaultIPPortItem),L"",IPPort.GetBuffer(MAX_PATH),MAX_PATH,m_configfile_path); IPPort.ReleaseBuffer(); GetPrivateProfileStringW(m_ISPTool_Section,CString(c_strCfgDefaultBaudrateItem),L"",BD.GetBuffer(MAX_PATH),MAX_PATH,m_configfile_path); BD.ReleaseBuffer(); GetPrivateProfileStringW(m_ISPTool_Section,CString(c_strCfgNote),L"",subnote.GetBuffer(MAX_PATH),MAX_PATH,m_configfile_path); subnote.ReleaseBuffer(); GetPrivateProfileStringW(m_ISPTool_Section,CString(c_strCfgSubID),L"",subID.GetBuffer(MAX_PATH),MAX_PATH,m_configfile_path); subID.ReleaseBuffer(); // HexFileName = m_szCfgFile[CV_TstatLastFlashFile]; // FlashMethod = m_szCfgFile[CV_TstatLastFlashMethod]; // DeviceID = m_szCfgFile[CV_TstatDeAddr]; // COMPORT = m_szCfgFile[CV_TstatDeCOM]; // BD = m_szCfgFile[CV_TstatDeBaudrate]; // IP=m_szCfgFile[CV_NCDeIP]; // IPPort=m_szCfgFile[CV_NCDeIPPort]; // subnote = m_szCfgFile[CV_SubNot]; // subID = m_szCfgFile[CV_Sub_ID]; // 取有效数据 //TCHAR c = ':'; // //HexFileName=HexFileName.Mid(HexFileName.Find(c)+2); //FlashMethod=FlashMethod.Mid(FlashMethod.Find(c)+2); //DeviceID=DeviceID.Mid(DeviceID.Find(c)+2); // COMPORT=COMPORT.Mid(2); //BD=BD.Mid(BD.Find(c)+2); //IP=IP.Mid(IP.Find(c)+2); //IPPort=IPPort.Mid(IPPort.Find(c)+2); //subnote = subnote.Mid(subnote.Find(c)+2); //subID = subID.Mid(subID.Find(c)+2); }
/************************************************************************** * DRIVER_GetLibName [internal] * */ BOOL DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz) { HKEY hKey, hSecKey; DWORD bufLen, lRet; static const WCHAR wszSystemIni[] = {'S','Y','S','T','E','M','.','I','N','I',0}; WCHAR wsznull = '\0'; /* This takes us as far as Windows NT\CurrentVersion */ lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, HKLM_BASE, 0, KEY_QUERY_VALUE, &hKey); if (lRet == ERROR_SUCCESS) { /* Now we descend into the section name that we were given */ lRet = RegOpenKeyExW(hKey, sectName, 0, KEY_QUERY_VALUE, &hSecKey); if (lRet == ERROR_SUCCESS) { /* Retrieve the desired value - this is the filename of the lib */ bufLen = sz; lRet = RegQueryValueExW(hSecKey, keyName, 0, 0, (void*)buf, &bufLen); RegCloseKey( hSecKey ); } RegCloseKey( hKey ); } /* Finish up if we've got what we want from the registry */ if (lRet == ERROR_SUCCESS) return TRUE; /* default to system.ini if we can't find it in the registry, * to support native installations where system.ini is still used */ return GetPrivateProfileStringW(sectName, keyName, &wsznull, buf, sz / sizeof(WCHAR), wszSystemIni); }
static BOOL Spelling_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { PSUGGARRAY psa = (PSUGGARRAY)lParam; int index; wchar_t szBuffer[512]; g_hSpellChecking = hwnd; if(psa->pSuggs){ SetPropW(hwnd, EDIT_PROP, (HANDLE)psa->hEdit); for(int i = 0; i < psa->count; i++){ index = SendDlgItemMessageW(hwnd, IDC_LST_MISPRINTS, LB_ADDSTRING, 0, (LPARAM)psa->pSuggs[i]->word); SendDlgItemMessageW(hwnd, IDC_LST_MISPRINTS, LB_SETITEMDATA, index, (LPARAM)psa->pSuggs[i]); } } GetPrivateProfileStringW(L"options", L"1052", L"Spell checking", szBuffer, 256, g_NotePaths.CurrLanguagePath); SetWindowTextW(hwnd, szBuffer); SetDlgCtlText(hwnd, IDCANCEL, g_NotePaths.CurrLanguagePath, L"Cancel"); SetDlgCtlText(hwnd, IDC_ST_NOT_IN_DICT, g_NotePaths.CurrLanguagePath, L"Not in dictionary"); SetDlgCtlText(hwnd, IDC_ST_SUGGESTIONS, g_NotePaths.CurrLanguagePath, L"Suggestions"); SetDlgCtlText(hwnd, IDC_CMD_IGNORE_ONCE, g_NotePaths.CurrLanguagePath, L"Ignore once"); SetDlgCtlText(hwnd, IDC_CMD_IGNORE_ALL, g_NotePaths.CurrLanguagePath, L"Ignore all"); SetDlgCtlText(hwnd, IDC_CMD_ADD_TO_DICT, g_NotePaths.CurrLanguagePath, L"Add to dictionary"); SetDlgCtlText(hwnd, IDC_CMD_CHANGE_ONCE, g_NotePaths.CurrLanguagePath, L"Change"); SetDlgCtlText(hwnd, IDC_CMD_CHANGE_ALL, g_NotePaths.CurrLanguagePath, L"Change all"); return TRUE; }
void LoadCredentails(const std::wstring& library, std::wstring& userName, std::wstring& password) { std::wstring configFileName = (const wchar_t*)_bstr_t(MWGetApplicationPath().c_str()); configFileName.append(L"dominodoc.ini"); //char configFileName[_MAX_PATH] = {0}; //::sprintf(configFileName, "%sdominodoc.ini", TEST_PATH_MAKE_ABSOLUTE(L"Win32\\Debug\\")); wchar_t value[_MAX_PATH] = {0}; GetPrivateProfileStringW(library.c_str(), L"userid", NULL, value, _MAX_PATH, configFileName.c_str()); userName = value; ZeroMemory(value, sizeof(value)); GetPrivateProfileStringW(library.c_str(), L"password", NULL, value, _MAX_PATH, configFileName.c_str()); password = EncryptPassword(false, value); }
void BaseTest::MakeRootPath(LPWSTR path, LPCWSTR name) { WCHAR filename[MAX_PATH]; if (0 == path[0]) { GetModuleFileNameW(NULL, filename, MAX_PATH); PathRemoveFileSpecW(filename); PathAppendW(filename, L"UnitTests.ini"); lstrcpynW(path, filename, MAX_PATH); PathRemoveFileSpecW(path); // bin\vc80\debug\tests PathRemoveFileSpecW(path); // bin\vc80\debug PathRemoveFileSpecW(path); // bin\vc80 PathRemoveFileSpecW(path); // bin PathAppendW(path, name); // bin\name GetPrivateProfileStringW(L"Path", name, path, path, MAX_PATH, filename); PathAddBackslashW(path); SetFileAttributesW(filename, FILE_ATTRIBUTE_NORMAL); WritePrivateProfileStringW(L"Path", name, path, filename); } }
static UINT ACTION_AppSearchIni(MSIPACKAGE *package, LPWSTR *appValue, MSISIGNATURE *sig) { static const WCHAR query[] = { 's','e','l','e','c','t',' ','*',' ', 'f','r','o','m',' ', 'I','n','i','L','o','c','a','t','o','r',' ', 'w','h','e','r','e',' ', 'S','i','g','n','a','t','u','r','e','_',' ','=',' ','\'','%','s','\'',0}; MSIRECORD *row; LPWSTR fileName, section, key; int field, type; WCHAR buf[MAX_PATH]; TRACE("%s\n", debugstr_w(sig->Name)); *appValue = NULL; row = MSI_QueryGetRecord( package->db, query, sig->Name ); if (!row) { TRACE("failed to query IniLocator for %s\n", debugstr_w(sig->Name)); return ERROR_SUCCESS; } fileName = msi_dup_record_field(row, 2); section = msi_dup_record_field(row, 3); key = msi_dup_record_field(row, 4); field = MSI_RecordGetInteger(row, 5); type = MSI_RecordGetInteger(row, 6); if (field == MSI_NULL_INTEGER) field = 0; if (type == MSI_NULL_INTEGER) type = 0; GetPrivateProfileStringW(section, key, NULL, buf, MAX_PATH, fileName); if (buf[0]) { switch (type & 0x0f) { case msidbLocatorTypeDirectory: ACTION_SearchDirectory(package, sig, buf, 0, appValue); break; case msidbLocatorTypeFileName: *appValue = app_search_file(buf, sig); break; case msidbLocatorTypeRawValue: *appValue = get_ini_field(buf, field); break; } } msi_free(fileName); msi_free(section); msi_free(key); msiobj_release(&row->hdr); return ERROR_SUCCESS; }
VOID CliGetPreloadKeyboardLayouts(FE_KEYBOARDS* pFeKbds) { UINT i; WCHAR szPreLoadee[4]; // up to 999 preloads WCHAR lpszName[KL_NAMELENGTH]; UNICODE_STRING UnicodeString; HKL hkl; for (i = 1; i < 1000; i++) { wsprintf(szPreLoadee, L"%d", i); if ((GetPrivateProfileStringW( L"Preload", szPreLoadee, L"", // default = NULL lpszName, // output buffer KL_NAMELENGTH, L"keyboardlayout.ini") == -1 ) || (*lpszName == L'\0')) { break; } RtlInitUnicodeString(&UnicodeString, lpszName); RtlUnicodeStringToInteger(&UnicodeString, 16L, (PULONG)&hkl); RIPMSG2(RIP_VERBOSE, "PreLoaded HKL(%d): %08X\n", i, hkl); // // Set language flags. By its definition, LOWORD(hkl) is LANGID // SetFeKeyboardFlags(LOWORD(HandleToUlong(hkl)), pFeKbds); } }
BOOL config_load_w(HMODULE module,CONFIG_BINDING_W* binding){ wchar_t path[MAX_PATH]; GetModuleFileNameW(module,path,MAX_PATH); for(int i=wcslen(path)-1;i>=0;i--){ if(path[i]==L'\\'){ path[i]=L'\0'; break; } } wcscat(path,L"\\config.ini"); PCONFIG_BINDING_W b; int i=0; wchar_t buffer[32767]; int l; while((b=binding+(i++))->section){ switch(b->type){ case CONFIG_TYPE_STRING: l = GetPrivateProfileStringW(b->section,b->key,b->def.asString,buffer,32767,path); if(buffer[0]==0&&b->def.asString==NULL){ *(b->val.asString)=NULL; }else{ *(b->val.asString)=(wchar_t*)malloc(sizeof(wchar_t)*(wcslen(buffer)+1)); wcscpy(*(b->val.asString),buffer); } break; case CONFIG_TYPE_INT: *(b->val.asInt) = GetPrivateProfileIntW(b->section,b->key,b->def.asInt,path); break; } } return TRUE; }
/************************************************************************** * DRIVER_GetLibName [internal] * */ BOOL DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz) { HKEY hKey, hSecKey; DWORD bufLen, lRet; static const WCHAR wszSystemIni[] = {'S','Y','S','T','E','M','.','I','N','I',0}; WCHAR wsznull = '\0'; TRACE("registry: %s, %s, %p, %d\n", debugstr_w(keyName), debugstr_w(sectName), buf, sz); lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, HKLM_BASE, 0, KEY_QUERY_VALUE, &hKey); if (lRet == ERROR_SUCCESS) { lRet = RegOpenKeyExW(hKey, sectName, 0, KEY_QUERY_VALUE, &hSecKey); if (lRet == ERROR_SUCCESS) { bufLen = sz; lRet = RegQueryValueExW(hSecKey, keyName, 0, 0, (void*)buf, &bufLen); RegCloseKey( hSecKey ); } RegCloseKey( hKey ); } if (lRet == ERROR_SUCCESS) return TRUE; /* default to system.ini if we can't find it in the registry, * to support native installations where system.ini is still used */ TRACE("system.ini: %s, %s, %p, %d\n", debugstr_w(keyName), debugstr_w(sectName), buf, sz); return GetPrivateProfileStringW(sectName, keyName, &wsznull, buf, sz / sizeof(WCHAR), wszSystemIni); }
BOOL CDlgBatteryParam::OnInitDialog() { CDialog::OnInitDialog(); m_batteryCell = -1; GetPrivateProfileStringW(_T("Prompt"),_T("MESSAGE_TITLE"),_T("MESSAGE_TITLE"), m_strMsgBoxTitle.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath); int n; LPWSTR lpDir; CString strTempPath; CString strSystemPath; lpDir=GetRootDir(); strSystemPath = (CString)lpDir; if(lpDir) { delete lpDir; } n = strSystemPath.ReverseFind('\\'); strTempPath = strSystemPath.Left(n); n = strTempPath.ReverseFind('\\'); strRootPath=strTempPath.Left(n); strResourceDtsPath= strRootPath+_T("\\dts\\Resource.dts"); strResourceDtbPath= strRootPath+_T("\\dts\\rk-kernel.dtb"); strResourcePath=strTempPath+"\\Android\\Image\\resource.img"; InitUIComponents(); //ReadBatteryParameters(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL bCheckIfDualBootingWithWin31() { WCHAR Buffer[32]; WCHAR awcWindowsDir[MAX_PATH]; DWORD dwRet; UINT cwchWinPath = GetWindowsDirectoryW(awcWindowsDir, MAX_PATH); // the cwchWinPath value does not include the terminating zero if (awcWindowsDir[cwchWinPath - 1] == L'\\') { cwchWinPath -= 1; } awcWindowsDir[cwchWinPath] = L'\0'; // make sure to zero terminated lstrcatW(awcWindowsDir, L"\\system32\\"); lstrcatW(awcWindowsDir, WINNT_GUI_FILE_W); dwRet = GetPrivateProfileStringW( WINNT_DATA_W, WINNT_D_WIN31UPGRADE_W, WINNT_A_NO_W, Buffer, sizeof(Buffer)/sizeof(WCHAR), awcWindowsDir ); #if DBG DbgPrint("\n dwRet = %ld, win31upgrade = %ws\n\n", dwRet, Buffer); #endif return (BOOL)(dwRet ? (!lstrcmpiW(Buffer,WINNT_A_YES)) : 0); }
wchar_t * LoadItemString(wchar_t * pItemID,wchar_t * pText,wchar_t * pDefault/* = NULL*/) { wchar_t * pLangFilePath = new wchar_t[1024]; memset(pLangFilePath,0,1024*sizeof(wchar_t)); GetCurrentDirectory(1024,pLangFilePath); wcscat(pLangFilePath,L"\\Language\\"); wcscat(pLangFilePath,FFD.cFileName); memset(pText,0,1024*sizeof(wchar_t)); if(GetPrivateProfileStringW(L"String",pItemID,L"", pText,1024,pLangFilePath) != 0) { delete [] pLangFilePath; return pText; } else { delete [] pLangFilePath; if(pDefault) { return pDefault; } else { return L""; } } }
BOOL read_appkey(LPCWSTR lpappname, /* 区段名 */ LPCWSTR lpkey, /* 键名 */ LPWSTR prefstring, /* 保存值缓冲区 */ DWORD bufsize /* 缓冲区大小 */ ) { DWORD res = 0; LPWSTR lpstring; if ( profile_path[1] != L':' ) { if (!ini_ready(profile_path,MAX_PATH)) { return res; } } lpstring = (LPWSTR)SYS_MALLOC(bufsize); res = GetPrivateProfileStringW(lpappname, lpkey ,L"", lpstring, bufsize, profile_path); if (res == 0 && GetLastError() != 0x0) { SYS_FREE(lpstring); return FALSE; } wcsncpy(prefstring,lpstring,bufsize/sizeof(WCHAR)-1); prefstring[res] = '\0'; SYS_FREE(lpstring); return ( res>0 ); }
float GetIniFloat2(wchar_t * lpAppName,wchar_t * lpKeyName,const wchar_t * lpFileName,const wchar_t * DefChar) { wchar_t ReadIniTMP[512]; float IniFloat=0.0f; GetPrivateProfileStringW(lpAppName,lpKeyName,DefChar,ReadIniTMP,512,lpFileName); swscanf_s(ReadIniTMP,L"%f",&IniFloat); return IniFloat; }
void CDlgBatteryParam::InitUIComponents() { CString strTxt; GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_TAB_TITLE"),_T("IDS_TAB_TITLE"), strTxt.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath); SetWindowText(strTxt); GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ONE_BATTERY"),_T("IDS_ONE_BATTERY"), strTxt.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath); GetDlgItem(IDC_RADIO_CELL_ONE)->SetWindowText(strTxt); GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_TWO_BATTERIES"),_T("IDS_TWO_BATTERIES"), strTxt.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath); GetDlgItem(IDC_RADIO_CELL_TWO)->SetWindowText(strTxt); GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_PULL_UP"),_T("IDS_PULL_UP"), strTxt.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath); GetDlgItem(IDC_STATIC_PULL_UP)->SetWindowText(strTxt); GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_PULL_DOWN"),_T("IDS_PULL_DOWN"), strTxt.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath); GetDlgItem(IDC_STATIC_PULL_DOWN)->SetWindowText(strTxt); GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_READ_BATTERY"),_T("IDS_READ_BATTERY"), strTxt.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath); GetDlgItem(IDC_BUTTON_READ_BATTERY)->SetWindowText(strTxt); GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_WRITE_BATTERY"),_T("IDS_WRITE_BATTERY"), strTxt.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath); GetDlgItem(IDC_BUTTON_WRITE_BATTERY)->SetWindowText(strTxt); GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_DISCHARGE"),_T("IDS_DISCHARGE"), strTxt.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath); GetDlgItem(IDC_GROUP_DISCHARGE)->SetWindowText(strTxt); GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_CHARGE"),_T("IDS_CHARGE"), strTxt.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath); GetDlgItem(IDC_GROUP_CHARGE)->SetWindowText(strTxt); GetPrivateProfileStringW(_T("BatteryParam"),_T("IDC_BTN_READ_BATTERY_DATA"),_T("IDC_BTN_READ_BATTERY_DATA"), strTxt.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath); GetDlgItem(IDC_BTN_READ_BATTERY_DATA)->SetWindowText(strTxt); strTxt.ReleaseBuffer(MAX_LENGTH); }
std::wstring LanguageSetting::GetLanguageW(TCHAR *key, TCHAR *name) { TCHAR str[255]; GetPrivateProfileStringW(key, name, L"", str, 255, L".\\lang.ini"); if (wcslen(str) == 0) { swprintf(str, L"Error: No Language keyname \"%s\" in Key \"%s\".", key, name); } return replaceAll(std::wstring(str), L"\\n", L"\n"); }
/* read the profile : fedExeNameChar; fomNameChar; fedNameChar */ void Hla::readIn( ) { TCHAR fedNameChar[256]; TCHAR userNameChar[256]; TCHAR fedExeNameChar[256]; TCHAR fomNameChar[256]; TCHAR crcAddressChar[256]; TCHAR crcPortChar[256]; TCHAR syncPointChar[256]; GetPrivateProfileString(L"GENERAL", L"FEDEXENAME", L"NO TEXT", fedExeNameChar, 256, Path); GetPrivateProfileString(L"GENERAL", L"FOMNAME", L"NO TEXT", fomNameChar, 256, Path); GetPrivateProfileString(L"GENERAL", L"CRC", L"NO TEXT", crcAddressChar, 256, Path); GetPrivateProfileString(L"GENERAL", L"CRC_PORT", L"NO TEXT", crcPortChar, 256, Path); GetPrivateProfileStringW(L"pub", L"FedName", L"NO TEXT", fedNameChar, 256, Path); //GetPrivateProfileStringW(L"sub", L"FedName", L"NO TEXT", fedNameChar, 256, Path); if (L"NO TEXT" == fedExeNameChar) { wcout << L"配置文件错误" << endl; wcout << L"联邦名称错误" << endl; system("pause"); } if (L"NO TEXT" == fomNameChar) { wcout << L"配置文件错误" << endl; wcout << L"Fom表名称错误" << endl; system("pause"); } if (L"NO TEXT" == crcAddressChar) { wcout << L"配置文件错误" << endl; wcout << L"crc地址错误" << endl; system("pause"); } if (L"NO TEXT" == crcPortChar) { wcout << L"配置文件错误" << endl; wcout << L"crc端口错误" << endl; system("pause"); } if (L"NO TEXT" == fedNameChar) { wcout << L"配置文件错误" << endl; wcout << L"fed名称错误" << endl; system("pause"); } fedExeName_ = fedExeNameChar; fomName_ = fomNameChar; crcAddress_ = crcAddressChar; crcPort_ = crcPortChar; fedName_ = fedNameChar; }
bool LoadSettingValue(const std::wstring& ini, const std::wstring& section, const wchar_t* param, std::wstring& value) { wchar_t tmp[4096] = { 0 }; if (!GetPrivateProfileStringW(section.c_str(), param, NULL, tmp, sizeof(tmp) / sizeof(*tmp), ini.c_str())) return false; if (GetLastError() == ERROR_FILE_NOT_FOUND) return false; value = tmp; return true; }
std::wstring PkyIniFileWrap::GetStringW( const wchar_t* pszSect, const wchar_t* pszKey, std::wstring const& strDefault) { WCHAR szWork[1024]; GetPrivateProfileStringW( pszSect, pszKey, strDefault.c_str(), szWork, _countof(szWork), m_strFileName.c_str() ); return std::wstring( szWork ); }
void CCommandObj::InitializationConfig(LPCWSTR lpConfigFileFullPath) { Out(Dbg,_T("Initialization Config Starting.")); m_ConfigCommon.usResourceServerPort = GetPrivateProfileIntW(L"System",L"ResourceServerPort",DEFAULT_CONFIG_SERVER_RESOURCE_PORT,lpConfigFileFullPath); m_ConfigCommon.usCommandServerPort = GetPrivateProfileIntW(L"System",L"CommandServerPort",DEFAULT_CONFIG_SERVER_COMMAND_PORT,lpConfigFileFullPath); m_ConfigCommon.dwRetrySleep = GetPrivateProfileIntW(L"Retry",L"RetrySleep",DEFAULT_CONFIG_RETRY_SLEEP,lpConfigFileFullPath); m_ConfigCommon.dwRetryCount = GetPrivateProfileIntW(L"Retry",L"RetryCount",DEFAULT_CONFIG_RETRY_COUNT,lpConfigFileFullPath); GetPrivateProfileStringW(L"System",L"ServerAddress",DEFAULT_CONFIG_SERVER_ADDRESS,m_ConfigCommon.szServerAddress,MAX_ADDRESS_STRING_LEN,lpConfigFileFullPath); Runend(true,_T("Initialization Config Stoping.")); }
static void do_parse_theme(WCHAR *file) { static const WCHAR colorSect[] = { 'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\', 'C','o','l','o','r','s',0}; WCHAR keyName[MAX_PATH], keyNameValue[MAX_PATH]; WCHAR *keyNamePtr = NULL; char *keyNameValueA = NULL; int keyNameValueSize = 0; int red = 0, green = 0, blue = 0; COLORREF color; WINE_TRACE("%s\n", wine_dbgstr_w(file)); GetPrivateProfileStringW(colorSect, NULL, NULL, keyName, MAX_PATH, file); keyNamePtr = keyName; while (*keyNamePtr!=0) { GetPrivateProfileStringW(colorSect, keyNamePtr, NULL, keyNameValue, MAX_PATH, file); keyNameValueSize = WideCharToMultiByte(CP_ACP, 0, keyNameValue, -1, keyNameValueA, 0, NULL, NULL); keyNameValueA = HeapAlloc(GetProcessHeap(), 0, keyNameValueSize); WideCharToMultiByte(CP_ACP, 0, keyNameValue, -1, keyNameValueA, keyNameValueSize, NULL, NULL); WINE_TRACE("parsing key: %s with value: %s\n", wine_dbgstr_w(keyNamePtr), wine_dbgstr_w(keyNameValue)); sscanf(keyNameValueA, "%d %d %d", &red, &green, &blue); color = RGB((BYTE)red, (BYTE)green, (BYTE)blue); HeapFree(GetProcessHeap(), 0, keyNameValueA); set_color_from_theme(keyNamePtr, color); keyNamePtr+=lstrlenW(keyNamePtr); keyNamePtr++; } }
static void SetListColumnText(HWND hwnd, int listID, int index, wchar_t * lpKey, wchar_t * lpDefault, wchar_t * lpFile){ LVCOLUMNW lvc = {0}; wchar_t szBuffer[256]; lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH; lvc.cchTextMax = 256; lvc.pszText = szBuffer; SendDlgItemMessageW(hwnd, listID, LVM_GETCOLUMNW, index, (LPARAM)&lvc); GetPrivateProfileStringW(S_COLUMNS, lpKey, lpDefault, szBuffer, 256, lpFile); SendDlgItemMessageW(hwnd, listID, LVM_SETCOLUMNW, index, (LPARAM)&lvc); }
static HRESULT process_hook_section(install_ctx_t *ctx, const WCHAR *sect_name) { WCHAR buf[2048], val[2*MAX_PATH]; const WCHAR *key; DWORD len; HRESULT hres; static const WCHAR runW[] = {'r','u','n',0}; len = GetPrivateProfileStringW(sect_name, NULL, NULL, buf, sizeof(buf)/sizeof(*buf), ctx->install_file); if(!len) return S_OK; for(key = buf; *key; key += strlenW(key)+1) { if(!strcmpiW(key, runW)) { WCHAR *cmd; size_t size; len = GetPrivateProfileStringW(sect_name, runW, NULL, val, sizeof(val)/sizeof(*val), ctx->install_file); TRACE("Run %s\n", debugstr_w(val)); expand_command(ctx, val, NULL, &size); cmd = heap_alloc(size*sizeof(WCHAR)); if(!cmd) heap_free(cmd); expand_command(ctx, val, cmd, &size); hres = RunSetupCommandW(ctx->hwnd, cmd, NULL, ctx->tmp_dir, NULL, NULL, 0, NULL); heap_free(cmd); if(FAILED(hres)) return hres; }else { FIXME("Unsupported hook %s\n", debugstr_w(key)); return E_NOTIMPL; } } return S_OK; }
void ndisks_load() { wchar_t tmp[SECTIONS_BUFFER_SIZE], sTmp[SECTIONS_BUFFER_SIZE], *pTmp, rTmp[SECTIONS_BUFFER_SIZE]; size_t i = 0, j = 0; NDisk disk; if(available_disks == NULL) { return; } wcslcpy(tmp, my_dir, SECTIONS_BUFFER_SIZE); wcscat_s(tmp, SECTIONS_BUFFER_SIZE, _config_file); GetPrivateProfileSectionNamesW(sTmp, SECTIONS_BUFFER_SIZE, tmp); for(i = 0; i < SECTIONS_BUFFER_SIZE; i++) { if(sTmp[0] == '\0') { break; } if(sTmp[i] == '\0') { pTmp = sTmp + j; if(!pTmp || wcscmp(pTmp, L"") == 0) { continue; } j = i + 1; memset(&disk, 0, sizeof(NDisk)); GetPrivateProfileStringW(pTmp, L"type", NULL, rTmp, SECTIONS_BUFFER_SIZE, tmp); if(!rTmp || wcscmp(rTmp, L"") == 0) { continue; } disk.type = _wcsdup(rTmp); GetPrivateProfileStringW(pTmp, L"username", NULL, rTmp, SECTIONS_BUFFER_SIZE, tmp); if(!rTmp || wcscmp(rTmp, L"") == 0) { free(disk.type); continue; } disk.username = _wcsdup(rTmp); disk.nickname = _wcsdup(pTmp); GetPrivateProfileStringW(pTmp, L"token", NULL, rTmp, SECTIONS_BUFFER_SIZE, tmp); disk.token = _wcsdup(rTmp); GetPrivateProfileStringW(pTmp, L"secret", NULL, rTmp, SECTIONS_BUFFER_SIZE, tmp); disk.secret = _wcsdup(rTmp); dict_set_element_s(available_disks, pTmp, &disk, sizeof(NDisk), ndisk_destroy_s); } } }
/*************************************************************************** * SHELL32_GetCustomFolderAttribute (internal function) * * Gets a value from the folder's desktop.ini file, if one exists. * * PARAMETERS * pidl [I] Folder containing the desktop.ini file. * pwszHeading [I] Heading in .ini file. * pwszAttribute [I] Attribute in .ini file. * pwszValue [O] Buffer to store value into. * cchValue [I] Size in characters including NULL of buffer pointed to * by pwszValue. * * RETURNS * TRUE if returned non-NULL value. * FALSE otherwise. */ static inline BOOL SHELL32_GetCustomFolderAttributeFromPath( LPWSTR pwszFolderPath, LPCWSTR pwszHeading, LPCWSTR pwszAttribute, LPWSTR pwszValue, DWORD cchValue) { static const WCHAR wszDesktopIni[] = {'d','e','s','k','t','o','p','.','i','n','i',0}; static const WCHAR wszDefault[] = {0}; PathAddBackslashW(pwszFolderPath); PathAppendW(pwszFolderPath, wszDesktopIni); return GetPrivateProfileStringW(pwszHeading, pwszAttribute, wszDefault, pwszValue, cchValue, pwszFolderPath); }
DWORD CIniFile::GetValue(const wchar_t *const pwchSection, const wchar_t *const pwchKeyWord, wchar_t *const pwchValue, const DWORD dwValueSize, const wchar_t *const pwchDefaultValue/*=NULL*/) { assert(NULL != pwchSection); assert(NULL != pwchKeyWord); assert(NULL != pwchValue); assert(dwValueSize > 0); return GetPrivateProfileStringW(pwchSection, pwchKeyWord, pwchDefaultValue, pwchValue, dwValueSize, m_wchPath); }