写了个CURL程序,在控制台下运行没问题,但改到MFC对话框程序里,就报了个“遇到问题需要关闭”的错误,求救,急~~难道控制台程序和MFC对话框程序有什么区别么?int CPC_IIUDlg::writeData(void *ptr, int size, int n, void *stream)
{
fp = fopen("d:\\temp.txt", "a+");
if(fp==NULL)
{
MessageBox("123",NULL,MB_OK);
}
int written = fwrite(ptr,size,n,fp);
char *dd;
return written;
}void CPC_IIUDlg::OnLook()
{
// TODO: Add your control notification handler code here
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl)
{
//fp = fopen("d:\\temp.txt", "a+");
char *cs;
char * p1="123";
curl_easy_setopt(curl,CURLOPT_POST,1); //个别状态监视
//getIdvStat
cs = "GetStat";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, cs);
curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.0.7:80/Net2.cgi");
char *s = getenv("REQUEST_METHOD");
char *data;
// curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
//GetDlgItem(IDC_EDIT3)->SetWindowText(data); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,writeData); curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
fclose(fp);
}
}
{
fp = fopen("d:\\temp.txt", "a+");
if(fp==NULL)
{
MessageBox("123",NULL,MB_OK);
}
int written = fwrite(ptr,size,n,fp);
char *dd;
return written;
}void CPC_IIUDlg::OnLook()
{
// TODO: Add your control notification handler code here
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl)
{
//fp = fopen("d:\\temp.txt", "a+");
char *cs;
char * p1="123";
curl_easy_setopt(curl,CURLOPT_POST,1); //个别状态监视
//getIdvStat
cs = "GetStat";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, cs);
curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.0.7:80/Net2.cgi");
char *s = getenv("REQUEST_METHOD");
char *data;
// curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
//GetDlgItem(IDC_EDIT3)->SetWindowText(data); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,writeData); curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
fclose(fp);
}
}
错误就在这一行,回调函数里不能对文件进行访问??
谢谢大家帮忙
控制台的主函数是MAIN,mfc是WINMAIN
控制台要自己写消息循环,MFC是消息映射