if((strstr(strurl, "http://cns.3721.com/cns.dll?fw=4&name=home&pid=")==NULL)&&(strstr(strurl, "about:blank")==NULL)&&(strstr(strurl, "sina.com.cn")==NULL)&&(strstr(strurl, "csdn.net")==NULL))
其中“http://cns.3721.com/cns.dll?fw=4&name=home&pid=”、"about:blank“、"sina.com.cn”、
"csdn.net“手工写上的,请问如果想把这些参数放在配置文件中,如何实现读取并使其相与?请高手帮忙!!谢谢!!!!
其中“http://cns.3721.com/cns.dll?fw=4&name=home&pid=”、"about:blank“、"sina.com.cn”、
"csdn.net“手工写上的,请问如果想把这些参数放在配置文件中,如何实现读取并使其相与?请高手帮忙!!谢谢!!!!
比如配置文件内容是:
;config.ini
[urls]
url1=http://cns.3721.com/cns.dll?fw=4&name=home&pid=
url2=about:blank然后下面的代码就可以读取键值url1的内容
char strBuf[200];
char iniFileName[MAX_PATH];// 这个参数必须包含Ini文件的全路径,如果只有文件名,文件必须在Windows目录中。
GetPrivateProfileString("urls","url1","",strBuf,200,iniFileName);
然后strBuf中就会包含字符串http://cns.3721.com/cns.dll?fw=4&name=home&pid=
相关的一组API是:
[GetPrivateProfileInt] Retrieves an integer associated with a key in the specified section of an initialization file.
[GetPrivateProfileSection] Retrieves all the keys and values for the specified section of an initialization file.
[GetPrivateProfileSectionNames] Retrieves the names of all sections in an initialization file.
[GetPrivateProfileString] Retrieves a string from the specified section in an initialization file.
[GetPrivateProfileStruct] Retrieves the data associated with a key in the specified section of an initialization file.
[GetProfileInt] Retrieves an integer from a key in the specified section of the Win.ini file.
[GetProfileSection] Retrieves all the keys and values for the specified section of the Win.ini file.
[GetProfileString] Retrieves the string associated with a key in the specified section of the Win.ini file.
[WritePrivateProfileSection] Replaces the keys and values for the specified section in an initialization file.
[WritePrivateProfileString] Copies a string into the specified section of an initialization file.
[WritePrivateProfileStruct] Copies data into a key in the specified section of an initialization file.
[WriteProfileSection] Replaces the contents of the specified section in the Win.ini file with specified keys and values.
[WriteProfileString] Copies a string into the specified section of the Win.ini file. 摘自MSDN
{
char tmp[20],strBuf[200];
char iniFileName[MAX_PATH];// 这个参数必须包含Ini文件的全路径,如果只有文件名,文件必须在Windows目录中。 for(int i=0;i<100;i++)
{
sprintf(tmp,"url%d",i);
if(GetPrivateProfileString("urls",tmp,"",strBuf,200,iniFileName))
{
if(strstr(strurl,strBuf)!=NULL))
//有一个条件不成立,退出
return FALSE;
}
else
//配置文件读取完毕,无更多网址列表
break;
}
//所有条件成立
return TRUE;
}