⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_24734.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:24734 发表者:lioa 发表日期:2002-12-16 09:23:21
<br>主题:这个函数是怎么用的?
<br>内容:m_csConnect=GetProfileString("Last DBConnect","DBConnect",NULL);<BR>请问这条语句是什么意思!<BR>这个函数是什么意思,用在什么地方的?<BR>请各位老大多多指教。
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:Norton AntiVirus 回复日期:2002-12-16 09:43:37
<br>内容:这个说起来很麻烦,不同的操作系统是不同的,具体可以参考MSDN中关于该函数的详细解释!!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:lioa 回复日期:2002-12-16 10:07:27
<br>内容:你好!我的操作系统是win2000啊 MSDN里提示说win.ini文件,可是我程序运行所在的操作系统下的win.ini文件里没有函数所用到的键值,m_csConnect却有返回值啊。是一个ODBC值。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:红塔山(2002) 回复日期:2002-12-16 10:21:00
<br>内容:CWinApp::GetProfileString <BR>CString GetProfileString( LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpszDefault = NULL );<BR><BR>Return Value<BR><BR>The return value is the string from the application’s .INI file or lpszDefault if the string cannot be found. The maximum string length supported by the framework is _MAX_PATH. If lpszDefault is NULL, the return value is an empty string.<BR><BR>Parameters<BR><BR>lpszSection<BR><BR>Points to a null-terminated string that specifies the section containing the entry.<BR><BR>lpszEntry<BR><BR>Points to a null-terminated string that contains the entry whose string is to be retrieved. This value must not be NULL.<BR><BR>lpszDefault<BR><BR>Points to the default string value for the given entry if the entry cannot be found in the initialization file.<BR><BR>Remarks<BR><BR>Call this member function to retrieve the string associated with an entry within the specified section in the application’s registry or .INI file.<BR><BR>The entries are stored as follows: <BR><BR>In Windows NT, the value is stored to a registry key.<BR><BR><BR>In Windows 3.x, the value is stored in the WIN.INI file. <BR><BR><BR>In Windows 95, the value is stored in a cached version of WIN.INI. <BR>Example<BR><BR>&nbsp;&nbsp; CString strSection&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = "My Section";<BR>&nbsp;&nbsp; CString strStringItem&nbsp;&nbsp;&nbsp;&nbsp;= "My String Item";<BR>&nbsp;&nbsp; CString strIntItem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = "My Int Item";<BR><BR>&nbsp;&nbsp; CWinApp* pApp = AfxGetApp();<BR><BR>&nbsp;&nbsp; pApp-&gt;WriteProfileString(strSection, strStringItem, "test");<BR><BR>&nbsp;&nbsp; CString strValue;<BR>&nbsp;&nbsp; strValue = pApp-&gt;GetProfileString(strSection, strStringItem);<BR>&nbsp;&nbsp; ASSERT(strValue == "test");<BR><BR>&nbsp;&nbsp; pApp-&gt;WriteProfileInt(strSection, strIntItem, 1234);<BR>&nbsp;&nbsp; int nValue;<BR>&nbsp;&nbsp; nValue = pApp-&gt;GetProfileInt(strSection, strIntItem, 0);<BR>&nbsp;&nbsp; ASSERT(nValue == 1234);<BR><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>
回复者:lioa 回复日期:2002-12-17 08:55:14
<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>
回复者:就这样被你征服 回复日期:2002-12-17 10:11:58
<br>内容:假设你的WIN。INI是这样的<BR>[SYSTEM]<BR>OS=WIN2000<BR>.<BR>.<BR>.<BR>.<BR>[MEDIA]<BR>AUDIO=0<BR>.<BR>.<BR>.<BR>那么你就应该知道m_csConnect=GetProfileString("SYSTEM","OS",NULL);<BR>这里m_csConnect就等于WIN2000,呵呵,应该清楚了吧<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>
回复者:lioa 回复日期:2002-12-17 10:59:17
<br>内容:回红塔山:<BR>  你所说的CWinApp::GetProfileString 与GetProfileString 不一样,你所说的函数在win2000底下是用来读注册表的。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:lioa 回复日期:2002-12-17 11:26:57
<br>内容:回就这样被你征服:<BR>&nbsp;&nbsp;&nbsp;&nbsp;我也是这样想的,但程序运行结果出乎我的意料,显示m_csConnect返回值是ODBC;DSN=oadb;......<BR>在win.ini文件中没有Last DBConnect这个项也没有这个值啊!<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>
<font color=red>答案被接受</font><br>回复者:就这样被你征服 回复日期:2002-12-19 20:11:09
<br>内容:你用的GetProfileString 应该就是CWinApp::GetProfileString,估计你的直试从注册表读出来的,你到注册表查查那个键直。<BR>我刚才看了MSDN,如果你用的是SDK的GetProfileString(),第三个参数是不能为NULL的。<BR><BR>DWORD GetProfileString(<BR>&nbsp;&nbsp;LPCTSTR lpAppName,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// section name<BR>&nbsp;&nbsp;LPCTSTR lpKeyName,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// key name<BR>&nbsp;&nbsp;LPCTSTR lpDefault,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// default string<BR>&nbsp;&nbsp;LPTSTR lpReturnedString,&nbsp;&nbsp;// destination buffer<BR>&nbsp;&nbsp;DWORD nSize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // size of destination buffer<BR>);<BR><BR>lpDefault <BR>[in] Pointer to a null-terminated default string. If the lpKeyName key cannot be found in the initialization file, GetProfileString copies the default string to the lpReturnedString buffer. This parameter cannot be NULL. <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 + -