s-->\r\n”,缓冲区,边界); //开放互联网连接 HINTERNET hSession=InternetOpen(“WINDOWS”,INTERNET\u OPEN\u TYPE\u Prefig,NULL,NULL,0); if(hsSession==NULL) { printf(“错误互联网开放”); getchar(); 返回错误\u打开\u文件; } printf(“互联网已打开”); HINTERNET hConnect=InternetConnect(会话、iaddr、INTERNET\u默认\u HTTP\u端口、NULL、NULL、INTERNET\u服务\u HTTP、0、1); 如果(hConnect==NULL) { printf(“网络连接错误”); getchar(); 返回错误\u互联网\u连接; } printf(“已连接互联网”); HINTERNET hRequest=HttpOpenRequest(hConnect,(const char*)“POST”、_T(url)、NULL、NULL、NULL、INTERNET_标志_重载,1); 如果(hRequest==NULL) { printf(“错误互联网请求”); getchar(); } printf(“互联网请求打开”); BOOL sent=HttpSendRequest(hRequest、hdrs、strlen(hdrs)、buffer、strlen(buffer)); 如果(!已发送) { printf(“错误互联网发送”); getchar(); 返回错误\u互联网\u连接; } printf(“互联网发送”确认\n); //关闭所有有效的internet句柄 InternetCloseHandle(hsSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); getchar(); 返回0; },c++,ftp,send,transfer,wininet,C++,Ftp,Send,Transfer,Wininet" /> s-->\r\n”,缓冲区,边界); //开放互联网连接 HINTERNET hSession=InternetOpen(“WINDOWS”,INTERNET\u OPEN\u TYPE\u Prefig,NULL,NULL,0); if(hsSession==NULL) { printf(“错误互联网开放”); getchar(); 返回错误\u打开\u文件; } printf(“互联网已打开”); HINTERNET hConnect=InternetConnect(会话、iaddr、INTERNET\u默认\u HTTP\u端口、NULL、NULL、INTERNET\u服务\u HTTP、0、1); 如果(hConnect==NULL) { printf(“网络连接错误”); getchar(); 返回错误\u互联网\u连接; } printf(“已连接互联网”); HINTERNET hRequest=HttpOpenRequest(hConnect,(const char*)“POST”、_T(url)、NULL、NULL、NULL、INTERNET_标志_重载,1); 如果(hRequest==NULL) { printf(“错误互联网请求”); getchar(); } printf(“互联网请求打开”); BOOL sent=HttpSendRequest(hRequest、hdrs、strlen(hdrs)、buffer、strlen(buffer)); 如果(!已发送) { printf(“错误互联网发送”); getchar(); 返回错误\u互联网\u连接; } printf(“互联网发送”确认\n); //关闭所有有效的internet句柄 InternetCloseHandle(hsSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); getchar(); 返回0; },c++,ftp,send,transfer,wininet,C++,Ftp,Send,Transfer,Wininet" />

如何修复此错误:未定义对`u imp_InternetOpenA'; #include <windows.h> #include <wininet.h> #include <stdio.h> #include <iostream> #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables static char filename[] = "test.txt"; //Filename to be loaded static char type[] = "image/jpg"; static char boundary[] = "pippo"; //Header boundary static char nameForm[] = "uploadedfile"; //Input form name static char iaddr[] = "localhost"; //IP address static char url[] = "test.php"; //URL char hdrs[255]; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filename , "rb" ); if (pFile==NULL) return ERROR_OPEN_FILE; // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) return ERROR_MEMORY; // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) return ERROR_SIZE; // terminate fclose (pFile); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n\r\n",buffer,type); sprintf(buffer,"%s%s\r\n",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WinSock",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) return ERROR_INTERNET_OPEN; HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) return ERROR_INTERNET_CONN; HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",url, NULL, NULL, (const char**)"*/*\0", 0, 1); if(hRequest==NULL) return ERROR_INTERNET_REQ; BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) return ERROR_INTERNET_SEND; //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); return 0; } </pre> 我想让C++程序把发送的.txt文件带到我的PC机上。我在网上搜索这么多,但找不到方法。 当我使用DEV C++时,会给我这样的错误: …:未定义对的引用 #include <windows.h> #include <wininet.h> #include <stdio.h> #include <iostream> #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables static char filename[] = "test.txt"; //Filename to be loaded static char type[] = "image/jpg"; static char boundary[] = "pippo"; //Header boundary static char nameForm[] = "uploadedfile"; //Input form name static char iaddr[] = "localhost"; //IP address static char url[] = "test.php"; //URL char hdrs[255]; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filename , "rb" ); if (pFile==NULL) return ERROR_OPEN_FILE; // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) return ERROR_MEMORY; // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) return ERROR_SIZE; // terminate fclose (pFile); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n\r\n",buffer,type); sprintf(buffer,"%s%s\r\n",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WinSock",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) return ERROR_INTERNET_OPEN; HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) return ERROR_INTERNET_CONN; HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",url, NULL, NULL, (const char**)"*/*\0", 0, 1); if(hRequest==NULL) return ERROR_INTERNET_REQ; BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) return ERROR_INTERNET_SEND; //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); return 0; } </pre> …:未定义对\u imp\u InternetConnectA'的引用 #include <windows.h> #include <wininet.h> #include <stdio.h> #include <iostream> #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables static char filename[] = "test.txt"; //Filename to be loaded static char type[] = "image/jpg"; static char boundary[] = "pippo"; //Header boundary static char nameForm[] = "uploadedfile"; //Input form name static char iaddr[] = "localhost"; //IP address static char url[] = "test.php"; //URL char hdrs[255]; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filename , "rb" ); if (pFile==NULL) return ERROR_OPEN_FILE; // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) return ERROR_MEMORY; // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) return ERROR_SIZE; // terminate fclose (pFile); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n\r\n",buffer,type); sprintf(buffer,"%s%s\r\n",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WinSock",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) return ERROR_INTERNET_OPEN; HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) return ERROR_INTERNET_CONN; HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",url, NULL, NULL, (const char**)"*/*\0", 0, 1); if(hRequest==NULL) return ERROR_INTERNET_REQ; BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) return ERROR_INTERNET_SEND; //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); return 0; } </pre> …:对的未定义引用\uuu imp\u FtpPutFileA' #include <windows.h> #include <wininet.h> #include <stdio.h> #include <iostream> #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables static char filename[] = "test.txt"; //Filename to be loaded static char type[] = "image/jpg"; static char boundary[] = "pippo"; //Header boundary static char nameForm[] = "uploadedfile"; //Input form name static char iaddr[] = "localhost"; //IP address static char url[] = "test.php"; //URL char hdrs[255]; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filename , "rb" ); if (pFile==NULL) return ERROR_OPEN_FILE; // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) return ERROR_MEMORY; // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) return ERROR_SIZE; // terminate fclose (pFile); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n\r\n",buffer,type); sprintf(buffer,"%s%s\r\n",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WinSock",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) return ERROR_INTERNET_OPEN; HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) return ERROR_INTERNET_CONN; HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",url, NULL, NULL, (const char**)"*/*\0", 0, 1); if(hRequest==NULL) return ERROR_INTERNET_REQ; BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) return ERROR_INTERNET_SEND; //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); return 0; } </pre> …:对\uu imp\u HttpOpenRequestA'的未定义引用 #include <windows.h> #include <wininet.h> #include <stdio.h> #include <iostream> #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables static char filename[] = "test.txt"; //Filename to be loaded static char type[] = "image/jpg"; static char boundary[] = "pippo"; //Header boundary static char nameForm[] = "uploadedfile"; //Input form name static char iaddr[] = "localhost"; //IP address static char url[] = "test.php"; //URL char hdrs[255]; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filename , "rb" ); if (pFile==NULL) return ERROR_OPEN_FILE; // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) return ERROR_MEMORY; // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) return ERROR_SIZE; // terminate fclose (pFile); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n\r\n",buffer,type); sprintf(buffer,"%s%s\r\n",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WinSock",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) return ERROR_INTERNET_OPEN; HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) return ERROR_INTERNET_CONN; HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",url, NULL, NULL, (const char**)"*/*\0", 0, 1); if(hRequest==NULL) return ERROR_INTERNET_REQ; BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) return ERROR_INTERNET_SEND; //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); return 0; } </pre> 下面是我找到的三个示例,但都返回了这个错误 <pre> #include <windows.h> #include <wininet.h> #include <iostream> #include <stdio.h> #include <tchar.h> #pragma comment(lib,"wininet.lib") #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables char filename[] = "file"; //Filename to be loaded char filepath[] = "d:\\a.jpg"; //Filename to be loaded char type[] = "image/jpeg"; char boundary[] = "--BOUNDARY---"; //Header boundary char nameForm[] = "formname"; //Input form name char iaddr[] = "localhost"; //IP address char url[] = "/http/file.php"; //URL char hdrs[512]={'-'}; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filepath , "rb" ); if (pFile==NULL) { printf("ERROR_OPEN_FILE"); getchar(); return ERROR_OPEN_FILE; } printf("OPEN_FILE\n"); // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) { printf("ERROR_MEMORY"); getchar(); return ERROR_OPEN_FILE; } printf("MEMORY_ALLOCATED\t \"%d\" \n",&lSize); // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) { printf("ERROR_SIZE"); getchar(); return ERROR_OPEN_FILE; } printf("SIZE_OK\n"); // terminate fclose (pFile); printf("FILE_CLOSE\n"); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"% ---------- s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n",buffer,type); sprintf(buffer,"%s%s",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WINDOWS",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) { printf("ERROR_INTERNET_OPEN"); getchar(); return ERROR_OPEN_FILE; } printf("INTERNET_OPENED\n"); HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) { printf("ERROR_INTERNET_CONN"); getchar(); return ERROR_INTERNET_CONN; } printf("INTERNET_CONNECTED\n"); HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",_T(url),NULL, NULL, NULL,INTERNET_FLAG_RELOAD, 1); if(hRequest==NULL) { printf("ERROR_INTERNET_REQ"); getchar(); } printf("INTERNET_REQ_OPEN\n"); BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) { printf("ERROR_INTERNET_SEND"); getchar(); return ERROR_INTERNET_CONN; } printf("INTERNET_SEND_OK\n"); //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); getchar(); return 0; } #包括 #包括 #包括 #包括 #包括 #pragma注释(lib,“wininet.lib”) #定义错误\u打开\u文件10 #定义错误\u存储器11 #定义错误\u大小12 #定义错误\u互联网\u打开13 #定义错误\u互联网\u连接14 #定义错误\u互联网\u请求15 #定义错误\u INTERNET\u发送16 使用名称空间std; int main() { //局部变量 char filename[]=“file”;//要加载的文件名 char filepath[]=“d:\\a.jpg”;//要加载的文件名 字符类型[]=“图像/jpeg”; 字符边界[]=“--boundary----”;//头边界 char nameForm[]=“formname”;//输入表单名称 char iaddr[]=“localhost”;//IP地址 字符url[]=“/http/file.php”;//url char hdrs[512]={'-'};//头 char*buffer;//包含文件+头的缓冲区 char*content;//包含文件的缓冲区 FILE*pFile;//文件指针 long lSize;//文件大小 结果的大小; //打开文件 pFile=fopen(文件路径,“rb”); if(pFile==NULL) { printf(“错误打开文件”); getchar(); 返回错误\u打开\u文件; } printf(“打开文件”); //获取文件大小: fseek(pFile,0,SEEK_END); lSize=ftell(pFile); 倒带(pFile); //分配内存以包含整个文件: 内容=(char*)malloc(sizeof(char)*lSize); if(content==NULL) { printf(“错误存储”); getchar(); 返回错误\u打开\u文件; } printf(“内存分配\t\%d\”\n“,&lSize); //将文件复制到缓冲区: 结果=fread(内容,1,lSize,pFile); 如果(结果!=lSize) { printf(“错误大小”); getchar(); 返回错误\u打开\u文件; } printf(“大小\u正常\n”); //终止 fclose(pFile); printf(“文件关闭”); //分配内存以包含整个文件+头 缓冲区=(char*)malloc(sizeof(char)*lSize+2048); //打印页眉 sprintf(hdrs,“内容类型:多部分/表单数据;边界=%s”,边界); sprintf(缓冲区,“%s\r\n内容处置:表单数据;名称=\%s\”文件名=\”% ---------- s \“\r\n”,边界,名称形式,文件名); sprintf(缓冲区,“%s内容类型:%s\r\n”,缓冲区,类型); sprintf(缓冲区,“%s%s”,缓冲区,内容); sprintf(缓冲区,“%s-->s-->\r\n”,缓冲区,边界); //开放互联网连接 HINTERNET hSession=InternetOpen(“WINDOWS”,INTERNET\u OPEN\u TYPE\u Prefig,NULL,NULL,0); if(hsSession==NULL) { printf(“错误互联网开放”); getchar(); 返回错误\u打开\u文件; } printf(“互联网已打开”); HINTERNET hConnect=InternetConnect(会话、iaddr、INTERNET\u默认\u HTTP\u端口、NULL、NULL、INTERNET\u服务\u HTTP、0、1); 如果(hConnect==NULL) { printf(“网络连接错误”); getchar(); 返回错误\u互联网\u连接; } printf(“已连接互联网”); HINTERNET hRequest=HttpOpenRequest(hConnect,(const char*)“POST”、_T(url)、NULL、NULL、NULL、INTERNET_标志_重载,1); 如果(hRequest==NULL) { printf(“错误互联网请求”); getchar(); } printf(“互联网请求打开”); BOOL sent=HttpSendRequest(hRequest、hdrs、strlen(hdrs)、buffer、strlen(buffer)); 如果(!已发送) { printf(“错误互联网发送”); getchar(); 返回错误\u互联网\u连接; } printf(“互联网发送”确认\n); //关闭所有有效的internet句柄 InternetCloseHandle(hsSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); getchar(); 返回0; }

如何修复此错误:未定义对`u imp_InternetOpenA'; #include <windows.h> #include <wininet.h> #include <stdio.h> #include <iostream> #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables static char filename[] = "test.txt"; //Filename to be loaded static char type[] = "image/jpg"; static char boundary[] = "pippo"; //Header boundary static char nameForm[] = "uploadedfile"; //Input form name static char iaddr[] = "localhost"; //IP address static char url[] = "test.php"; //URL char hdrs[255]; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filename , "rb" ); if (pFile==NULL) return ERROR_OPEN_FILE; // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) return ERROR_MEMORY; // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) return ERROR_SIZE; // terminate fclose (pFile); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n\r\n",buffer,type); sprintf(buffer,"%s%s\r\n",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WinSock",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) return ERROR_INTERNET_OPEN; HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) return ERROR_INTERNET_CONN; HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",url, NULL, NULL, (const char**)"*/*\0", 0, 1); if(hRequest==NULL) return ERROR_INTERNET_REQ; BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) return ERROR_INTERNET_SEND; //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); return 0; } </pre> 我想让C++程序把发送的.txt文件带到我的PC机上。我在网上搜索这么多,但找不到方法。 当我使用DEV C++时,会给我这样的错误: …:未定义对的引用 #include <windows.h> #include <wininet.h> #include <stdio.h> #include <iostream> #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables static char filename[] = "test.txt"; //Filename to be loaded static char type[] = "image/jpg"; static char boundary[] = "pippo"; //Header boundary static char nameForm[] = "uploadedfile"; //Input form name static char iaddr[] = "localhost"; //IP address static char url[] = "test.php"; //URL char hdrs[255]; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filename , "rb" ); if (pFile==NULL) return ERROR_OPEN_FILE; // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) return ERROR_MEMORY; // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) return ERROR_SIZE; // terminate fclose (pFile); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n\r\n",buffer,type); sprintf(buffer,"%s%s\r\n",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WinSock",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) return ERROR_INTERNET_OPEN; HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) return ERROR_INTERNET_CONN; HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",url, NULL, NULL, (const char**)"*/*\0", 0, 1); if(hRequest==NULL) return ERROR_INTERNET_REQ; BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) return ERROR_INTERNET_SEND; //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); return 0; } </pre> …:未定义对\u imp\u InternetConnectA'的引用 #include <windows.h> #include <wininet.h> #include <stdio.h> #include <iostream> #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables static char filename[] = "test.txt"; //Filename to be loaded static char type[] = "image/jpg"; static char boundary[] = "pippo"; //Header boundary static char nameForm[] = "uploadedfile"; //Input form name static char iaddr[] = "localhost"; //IP address static char url[] = "test.php"; //URL char hdrs[255]; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filename , "rb" ); if (pFile==NULL) return ERROR_OPEN_FILE; // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) return ERROR_MEMORY; // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) return ERROR_SIZE; // terminate fclose (pFile); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n\r\n",buffer,type); sprintf(buffer,"%s%s\r\n",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WinSock",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) return ERROR_INTERNET_OPEN; HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) return ERROR_INTERNET_CONN; HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",url, NULL, NULL, (const char**)"*/*\0", 0, 1); if(hRequest==NULL) return ERROR_INTERNET_REQ; BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) return ERROR_INTERNET_SEND; //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); return 0; } </pre> …:对的未定义引用\uuu imp\u FtpPutFileA' #include <windows.h> #include <wininet.h> #include <stdio.h> #include <iostream> #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables static char filename[] = "test.txt"; //Filename to be loaded static char type[] = "image/jpg"; static char boundary[] = "pippo"; //Header boundary static char nameForm[] = "uploadedfile"; //Input form name static char iaddr[] = "localhost"; //IP address static char url[] = "test.php"; //URL char hdrs[255]; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filename , "rb" ); if (pFile==NULL) return ERROR_OPEN_FILE; // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) return ERROR_MEMORY; // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) return ERROR_SIZE; // terminate fclose (pFile); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n\r\n",buffer,type); sprintf(buffer,"%s%s\r\n",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WinSock",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) return ERROR_INTERNET_OPEN; HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) return ERROR_INTERNET_CONN; HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",url, NULL, NULL, (const char**)"*/*\0", 0, 1); if(hRequest==NULL) return ERROR_INTERNET_REQ; BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) return ERROR_INTERNET_SEND; //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); return 0; } </pre> …:对\uu imp\u HttpOpenRequestA'的未定义引用 #include <windows.h> #include <wininet.h> #include <stdio.h> #include <iostream> #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables static char filename[] = "test.txt"; //Filename to be loaded static char type[] = "image/jpg"; static char boundary[] = "pippo"; //Header boundary static char nameForm[] = "uploadedfile"; //Input form name static char iaddr[] = "localhost"; //IP address static char url[] = "test.php"; //URL char hdrs[255]; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filename , "rb" ); if (pFile==NULL) return ERROR_OPEN_FILE; // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) return ERROR_MEMORY; // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) return ERROR_SIZE; // terminate fclose (pFile); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n\r\n",buffer,type); sprintf(buffer,"%s%s\r\n",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WinSock",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) return ERROR_INTERNET_OPEN; HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) return ERROR_INTERNET_CONN; HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",url, NULL, NULL, (const char**)"*/*\0", 0, 1); if(hRequest==NULL) return ERROR_INTERNET_REQ; BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) return ERROR_INTERNET_SEND; //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); return 0; } </pre> 下面是我找到的三个示例,但都返回了这个错误 <pre> #include <windows.h> #include <wininet.h> #include <iostream> #include <stdio.h> #include <tchar.h> #pragma comment(lib,"wininet.lib") #define ERROR_OPEN_FILE 10 #define ERROR_MEMORY 11 #define ERROR_SIZE 12 #define ERROR_INTERNET_OPEN 13 #define ERROR_INTERNET_CONN 14 #define ERROR_INTERNET_REQ 15 #define ERROR_INTERNET_SEND 16 using namespace std; int main() { // Local variables char filename[] = "file"; //Filename to be loaded char filepath[] = "d:\\a.jpg"; //Filename to be loaded char type[] = "image/jpeg"; char boundary[] = "--BOUNDARY---"; //Header boundary char nameForm[] = "formname"; //Input form name char iaddr[] = "localhost"; //IP address char url[] = "/http/file.php"; //URL char hdrs[512]={'-'}; //Headers char * buffer; //Buffer containing file + headers char * content; //Buffer containing file FILE * pFile; //File pointer long lSize; //File size size_t result; // Open file pFile = fopen ( filepath , "rb" ); if (pFile==NULL) { printf("ERROR_OPEN_FILE"); getchar(); return ERROR_OPEN_FILE; } printf("OPEN_FILE\n"); // obtain file size: fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); // allocate memory to contain the whole file: content = (char*) malloc (sizeof(char)*lSize); if (content == NULL) { printf("ERROR_MEMORY"); getchar(); return ERROR_OPEN_FILE; } printf("MEMORY_ALLOCATED\t \"%d\" \n",&lSize); // copy the file into the buffer: result = fread (content,1,lSize,pFile); if (result != lSize) { printf("ERROR_SIZE"); getchar(); return ERROR_OPEN_FILE; } printf("SIZE_OK\n"); // terminate fclose (pFile); printf("FILE_CLOSE\n"); //allocate memory to contain the whole file + HEADER buffer = (char*) malloc (sizeof(char)*lSize + 2048); //print header sprintf(hdrs,"Content-Type: multipart/form-data; boundary=%s",boundary); sprintf(buffer,"%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"% ---------- s\"\r\n",boundary,nameForm,filename); sprintf(buffer,"%sContent-Type: %s\r\n",buffer,type); sprintf(buffer,"%s%s",buffer,content); sprintf(buffer,"%s--%s--\r\n",buffer,boundary); //Open internet connection HINTERNET hSession = InternetOpen("WINDOWS",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if(hSession==NULL) { printf("ERROR_INTERNET_OPEN"); getchar(); return ERROR_OPEN_FILE; } printf("INTERNET_OPENED\n"); HINTERNET hConnect = InternetConnect(hSession, iaddr,INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); if(hConnect==NULL) { printf("ERROR_INTERNET_CONN"); getchar(); return ERROR_INTERNET_CONN; } printf("INTERNET_CONNECTED\n"); HINTERNET hRequest = HttpOpenRequest(hConnect, (const char*)"POST",_T(url),NULL, NULL, NULL,INTERNET_FLAG_RELOAD, 1); if(hRequest==NULL) { printf("ERROR_INTERNET_REQ"); getchar(); } printf("INTERNET_REQ_OPEN\n"); BOOL sent= HttpSendRequest(hRequest, hdrs, strlen(hdrs), buffer, strlen(buffer)); if(!sent) { printf("ERROR_INTERNET_SEND"); getchar(); return ERROR_INTERNET_CONN; } printf("INTERNET_SEND_OK\n"); //close any valid internet-handles InternetCloseHandle(hSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); getchar(); return 0; } #包括 #包括 #包括 #包括 #包括 #pragma注释(lib,“wininet.lib”) #定义错误\u打开\u文件10 #定义错误\u存储器11 #定义错误\u大小12 #定义错误\u互联网\u打开13 #定义错误\u互联网\u连接14 #定义错误\u互联网\u请求15 #定义错误\u INTERNET\u发送16 使用名称空间std; int main() { //局部变量 char filename[]=“file”;//要加载的文件名 char filepath[]=“d:\\a.jpg”;//要加载的文件名 字符类型[]=“图像/jpeg”; 字符边界[]=“--boundary----”;//头边界 char nameForm[]=“formname”;//输入表单名称 char iaddr[]=“localhost”;//IP地址 字符url[]=“/http/file.php”;//url char hdrs[512]={'-'};//头 char*buffer;//包含文件+头的缓冲区 char*content;//包含文件的缓冲区 FILE*pFile;//文件指针 long lSize;//文件大小 结果的大小; //打开文件 pFile=fopen(文件路径,“rb”); if(pFile==NULL) { printf(“错误打开文件”); getchar(); 返回错误\u打开\u文件; } printf(“打开文件”); //获取文件大小: fseek(pFile,0,SEEK_END); lSize=ftell(pFile); 倒带(pFile); //分配内存以包含整个文件: 内容=(char*)malloc(sizeof(char)*lSize); if(content==NULL) { printf(“错误存储”); getchar(); 返回错误\u打开\u文件; } printf(“内存分配\t\%d\”\n“,&lSize); //将文件复制到缓冲区: 结果=fread(内容,1,lSize,pFile); 如果(结果!=lSize) { printf(“错误大小”); getchar(); 返回错误\u打开\u文件; } printf(“大小\u正常\n”); //终止 fclose(pFile); printf(“文件关闭”); //分配内存以包含整个文件+头 缓冲区=(char*)malloc(sizeof(char)*lSize+2048); //打印页眉 sprintf(hdrs,“内容类型:多部分/表单数据;边界=%s”,边界); sprintf(缓冲区,“%s\r\n内容处置:表单数据;名称=\%s\”文件名=\”% ---------- s \“\r\n”,边界,名称形式,文件名); sprintf(缓冲区,“%s内容类型:%s\r\n”,缓冲区,类型); sprintf(缓冲区,“%s%s”,缓冲区,内容); sprintf(缓冲区,“%s-->s-->\r\n”,缓冲区,边界); //开放互联网连接 HINTERNET hSession=InternetOpen(“WINDOWS”,INTERNET\u OPEN\u TYPE\u Prefig,NULL,NULL,0); if(hsSession==NULL) { printf(“错误互联网开放”); getchar(); 返回错误\u打开\u文件; } printf(“互联网已打开”); HINTERNET hConnect=InternetConnect(会话、iaddr、INTERNET\u默认\u HTTP\u端口、NULL、NULL、INTERNET\u服务\u HTTP、0、1); 如果(hConnect==NULL) { printf(“网络连接错误”); getchar(); 返回错误\u互联网\u连接; } printf(“已连接互联网”); HINTERNET hRequest=HttpOpenRequest(hConnect,(const char*)“POST”、_T(url)、NULL、NULL、NULL、INTERNET_标志_重载,1); 如果(hRequest==NULL) { printf(“错误互联网请求”); getchar(); } printf(“互联网请求打开”); BOOL sent=HttpSendRequest(hRequest、hdrs、strlen(hdrs)、buffer、strlen(buffer)); 如果(!已发送) { printf(“错误互联网发送”); getchar(); 返回错误\u互联网\u连接; } printf(“互联网发送”确认\n); //关闭所有有效的internet句柄 InternetCloseHandle(hsSession); InternetCloseHandle(hConnect); InternetCloseHandle(hRequest); getchar(); 返回0; },c++,ftp,send,transfer,wininet,C++,Ftp,Send,Transfer,Wininet,#包括 #包括 #包括 #包括 #包括 #包括 //#pragma注释(lib,“wininet.lib”) 使用名称空间std; int main() { 静态TCHAR frmdata[]=“-------------------------------------7d82751e2bc0858\n内容处理:表单数据;名称=\“uploadedfile\”;文件名=\“C:\test.txt\”\n内容类型:text/plain\n\n此处文件内容\n--------------------


#包括
#包括
#包括
#包括
#包括
#包括
//#pragma注释(lib,“wininet.lib”)
使用名称空间std;
int main()
{
静态TCHAR frmdata[]=“-------------------------------------7d82751e2bc0858\n内容处理:表单数据;名称=\“uploadedfile\”;文件名=\“C:\test.txt\”\n内容类型:text/plain\n\n此处文件内容\n----------------------------7d82751e2bc0858-”;
静态TCHAR hdrs[]=“内容类型:多部分/表单数据;边界=------------------------------------7d82751e2bc0858”;
HINTERNET hSession=互联网开放(“MyAgent”,互联网开放类型,空,空,0);
if(hsSession==NULL)
{

CUT

我在第一个C++程序中有很多这样的错误。这是一个与WiNeNET库链接的问题。如果你使用的是明文添加“-LWInIt”(没有引号)如果使用VC++,我不知道该怎么办。另外,请确保WinINet库的位置位于链接器的搜索路径中。

使用CMake,您只需要