本文整理汇总了C++中GetPrivateProfileStringW函数的典型用法代码示例。如果您正苦于以下问题:C++ GetPrivateProfileStringW函数的具体用法?C++ GetPrivateProfileStringW怎么用?C++ GetPrivateProfileStringW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetPrivateProfileStringW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_profile_string
/* 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;
}
示例2: swprintf
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");
}
示例3: PersistFile_Load
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;
}
示例4: install_inf_file
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;
}
示例5: GetPrivateProfileStringW
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);
}
示例6: DRIVER_GetLibName
/**************************************************************************
* 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);
}
示例7: Spelling_OnInitDialog
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;
}
示例8: LoadCredentails
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);
}
示例9: GetModuleFileNameW
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);
}
}
示例10: ACTION_AppSearchIni
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;
}
示例11: CliGetPreloadKeyboardLayouts
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);
}
}
示例12: config_load_w
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;
}
示例13: DRIVER_GetLibName
/**************************************************************************
* 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);
}
示例14: GetPrivateProfileStringW
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
}
示例15: bCheckIfDualBootingWithWin31
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);
}