wininet

How can I prevent URLDownloadToFile from retrieving from the cache?

孤者浪人 提交于 2019-11-28 12:38:33
I am using URLDownloadToFile to retrieve a file from a website. Subsequent calls return the original file rather than an updated version. I assume it is retrieving a cached version. Call DeleteUrlCacheEntry with the same URL just prior to calling URLDownloadToFile. You will need to link against Wininet.lib Yes, it is pulling a cached version of the file by default. To avoid the cache file completely, pass an IBindStatusCallback object in the lpfnCB parameter of URLDownloadToFile(). In your implemented IBindStatusCallback::GetBindInfo() method, include the BINDF_GETNEWESTVERSION flag, and

Upload file via POST

五迷三道 提交于 2019-11-28 11:48:59
I have the necessity to implements a file upload on a web server in C++, I succeed with the following code: #include <windows.h> #include <wininet.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[] =

Client authentication (certificat + private key) using WinInet

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 10:19:20
问题 This is an evolution of my previous question, which was about WinHttp. I hope this is the right way to do this... I'm trying to communicate in https with a server using WinInet (from the Win32 API). Here is a very minimalist code : HINTERNET ses = InternetOpen("test",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0) ; HINTERNET con = InternetOpenUrl( ses,"https://stackoverflow.com",NULL,0,0,0 ) ; DWORD read ; char str [3000] ; InternetReadFile( con,reinterpret_cast<void*>( str ),sizeof( str )-1,&read )

How to clear MSIE/WinInet cache programmatically?

≡放荡痞女 提交于 2019-11-28 09:20:46
问题 I'm trying to clear out the WinInet cache using Win32 API - by invalidating the cache entries, or deleting them (doesn't matter). I can't find any way to do this for the whole cache (other than iterating over each entry - example in C#, another in VB) - is this even possible? 回答1: I'm fairly certain doing the FindFirst/FindNextUrlCacheEntry() then DeleteUrlCacheEntry() is the only way to make sure it works across all versions of IE. Alternatively you can use FindFirst/FindNextUrlCacheGroup()

Using WinInet to identify total file size before downloading it

随声附和 提交于 2019-11-28 09:18:51
I got the source below from a third-party site explaining how to download a file from the internet using WinInet . I'm not too familiar with API, and I took at look at the WinInet unit but did not see any API calls like what I need. What I'm doing is adding the ability to report back progress of downloading a file. This procedure I've already wrapped inside of a TThread and everything works fine. However, just one missing piece: Finding the total size of the source file before downloading. See below where I have a comment //HOW TO GET TOTAL SIZE? This is where I need to find out what is the

TCP Keep Alive on idHttpServer (server) and wininet (client)

孤者浪人 提交于 2019-11-28 04:26:36
问题 I have a webserver application developed using idHttpServer. When a client connects do my webserver and, for some unknown reason, got disconnect (not a gracefully disconnect) my webserver does not get notified. I know this is the normal behavior but I need to know when the client dies. There are a few ways of doing this. I know 2 good ways: 1 - Implement a heart beat mechanism. The client socket notifies the server that it is still alive (need some work and some code to make it works) 2 - TCP

How do I figure out the correct argument structure for an unmanaged dll?

核能气质少年 提交于 2019-11-28 02:07:20
I was loading in some old VB functions from VBA, and mostly got everything updated to VB.NET, but there are function declarations for functions in "wininet.dll" which don't seem to match up correctly. The Error I'm getting is: Exception Thrown: Managed Debugging Assistant, 'PInvokeStackImbalance':... The long and short of it is that the length of the declared arguments needs to be explicit and it isn't matching up to the real functions in the dll. I looked this up and I can get by just removing the checks, but it will have a "stack imbalance" and eventually eat up all the stack over time as

Dev C++ Wininet Upload file using HTTP

泄露秘密 提交于 2019-11-28 02:06:11
问题 I want to upload "C:\test.txt" to webserver, when I am running program, file is not uploading and I am not getting any error. the complete C++ code can be find here and php code on webserver can be find here: "http://student114.110mb.com/upload.txt" or "http://student114.110mb.com/upload.php" kindly help me where I am doing wrong #include <windows.h> #include <wininet.h> #include <tchar.h> #include <iostream> #pragma comment(lib,"wininet.lib") using namespace std; int main() { static TCHAR

Why is FormatMessage() failing to find a message for WinINet errors?

筅森魡賤 提交于 2019-11-27 23:35:43
I'm running this to test FormatMessage : LPVOID lpMsgBuf; errCode=12163; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM , 0, errCode, 0, (LPTSTR) &lpMsgBuf, 0, NULL ); However, when it returns lpMsgBuf contains NULL... I was expecting something like ERROR_INTERNET_DISCONNECTED . Anything look wrong? Thanks. Shog9 That's a WinINet error, and so the message associated with it lives in WinINet.dll. You just need to tell FormatMessage() about this in order for it to retrieve the correct message: FormatMessage( // flags: FORMAT_MESSAGE_ALLOCATE_BUFFER // allocate buffer

Detect an internet connection activation with Delphi

风格不统一 提交于 2019-11-27 07:20:23
I've been using a 3G wireless card for a while and every time I connect, my anti-virus fires up the updates. I'm wondering what is the Win32 API set of functions that I can use to, either, get notified or query about the event of an Internet Connection coming up? And is there already a set of ported headers for Delphi? I worked on a project to run a user's logon script whenever they connected our network over VPN. To do this, I wrote a helper unit that retrieves adapter info and stores it into a simple record. I then setup up a registry notification, see here for how to do that in Delphi The