📄 subject_57655.htm
字号:
<p>
序号:57655 发表者:chao_jie 发表日期:2003-10-27 14:09:56
<br>主题:writeprofileint 和 getprofileint 问题求教
<br>内容:这两个函数用来注册信息,在msdn6.0里这样描述<BR><BR>The entries are stored as follows: <BR><BR>In Windows NT, the value is stored to a registry key.<BR>In Windows 3.x, the value is stored in the WIN.INI file. <BR>In Windows 95, the value is stored in a cached version of WIN.INI. <BR><BR>在windows2000里是存到那里?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:redjean 回复日期:2003-10-27 15:41:01
<br>内容:应该和NT一样的。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:redleaf 回复日期:2003-10-27 18:29:53
<br>内容:试一下吧,实践了才知道
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:chao_jie 回复日期:2003-10-31 13:20:14
<br>内容:和NT是一样的,写到 _CURRANT_USER\SOFTWARE\ 下了<BR><BR>有那位高手知道,怎么把 writeprofileint 改成写到某个 .ini 文件吗?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:redleaf 回复日期:2003-10-31 14:14:02
<br>内容:用WritePrivateProfileString<BR>MSDN中的例子<BR>// include files <BR>#include <stdio.h> <BR>#include <windows.h> <BR> <BR>// a main function <BR>main() <BR> <BR>{ <BR> // local variables <BR> CHAR inBuf[80]; <BR> HKEY hKey1, hKey2; <BR> DWORD dwDisposition; <BR> LONG lRetCode; <BR> <BR> // try to create the .ini file key <BR> lRetCode = RegCreateKeyEx ( HKEY_LOCAL_MACHINE, <BR> "SOFTWARE\\Microsoft\\Windows NT <BR> \\CurrentVersion\\IniFileMapping\\appname.ini", <BR> 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, <BR> NULL, &hKey1, <BR> &dwDisposition); <BR> <BR> // if we failed, note it, and leave <BR> if (lRetCode != ERROR_SUCCESS){ <BR> printf ("Error in creating appname.ini key\n"); <BR> return (0) ; <BR> } <BR> <BR> // try to set a section value <BR> lRetCode = RegSetValueEx ( hKey1, <BR> "Section1", <BR> 0, <BR> REG_SZ, <BR> "USR:App Name\\Section1", <BR> 20); <BR> <BR> // if we failed, note it, and leave <BR> if (lRetCode != ERROR_SUCCESS) { <BR> printf ( "Error in setting Section1 value\n"); <BR> return (0) ; <BR> } <BR> <BR> // try to create an App Name key <BR> lRetCode = RegCreateKeyEx ( HKEY_CURRENT_USER, <BR> "App Name", <BR> 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, <BR> NULL, &hKey2, <BR> &dwDisposition); <BR> <BR> // if we failed, note it, and leave <BR> if (lRetCode != ERROR_SUCCESS) { <BR> printf ("Error in creating App Name key\n"); <BR> return (0) ; <BR> } <BR> <BR> // force the system to re-read the mapping into shared memory <BR> // so that future invocations of the application will see it <BR> // without the user having to reboot the system <BR> WritePrivateProfileStringW( NULL, NULL, NULL, L"appname.ini" ); <BR> <BR> // if we get this far, all has gone well <BR> // let's write some added values <BR> WritePrivateProfileString ("Section1", "FirstKey", <BR> "It all worked out okay.", "appname.ini"); <BR> WritePrivateProfileString ("Section1", "SecondKey", <BR> "By golly, it works.", "appname.ini"); <BR> WritePrivateProfileSection ("Section1", "ThirdKey = Another Test.", <BR> "appname.ini"); <BR> <BR> // let's test our work <BR> GetPrivateProfileString ("Section1", "FirstKey", <BR> "Bogus Value: Get didn't work", inBuf, 80, <BR> "appname.ini"); <BR> printf ("%s", inBuf); <BR> <BR> // okay, we are outta here <BR> return(0); <BR> <BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -