添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register or Login before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. hello,
i'm using wininet sdk having problem while i'm unloading wininet.dll.
here is seudocode
HMODULE hDll;
bool ret;
HINTERNET hInternet, hUrlHandle ;
char buf[1000];
hDll = LoadLibrary("wininet.dll");
// ret = FreeLibrary(hDll);
typedef HINTERNET ( WINAPI *InternetOpen ) (LPCTSTR , DWORD ,LPCTSTR,LPCTSTR ,DWORD );
typedef HINTERNET ( WINAPI *InternetOpenUrl) ( HINTERNET, LPCTSTR , LPCTSTR , DWORD , DWORD , DWORD);
typedef BOOL (WINAPI *HttpQueryInfo) (HINTERNET,DWORD,LPVOID ,LPDWORD ,LPDWORD);
typedef BOOL (WINAPI *InternetCloseHandle) ( HINTERNET );
typedef BOOL ( WINAPI * InternetReadFile ) (HINTERNET ,LPVOID ,DWORD ,LPDWORD) ;
InternetOpen f1;
InternetOpenUrl f2;
HttpQueryInfo f3;
InternetCloseHandle f4;
InternetReadFile f5;
f1 = ( InternetOpen ) GetProcAddress( hDll, "InternetOpenA" );
f2 = (InternetOpenUrl ) GetProcAddress ( hDll, "InternetOpenUrlA");
f3 = (HttpQueryInfo) GetProcAddress ( hDll, "HttpQueryInfoA");
f4 = (InternetCloseHandle) GetProcAddress (hDll,"InternetCloseHandle");
f5 = (InternetReadFile) GetProcAddress(hDll,"InternetReadFile");
hInternet = (*f1)("MSMSGS", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_NO_COOKIES + INTERNET_FLAG_NO_UI + INTERNET_FLAG_PRAGMA_NOCACHE /* + INTERNET_FLAG_SECURE */);
//hUrlHandle = InternetOpenUrl(hInternet,szURL, szAuth , DWORD (-1), INTERNET_FLAG_NO_COOKIES + INTERNET_FLAG_NO_AUTO_REDIRECT, 0);
hUrlHandle = (*f2)(hInternet, "http://www.microsoft.com" /*szURL*/, ""/*szAuth */, DWORD (-1), INTERNET_FLAG_NO_COOKIES + INTERNET_FLAG_NO_AUTO_REDIRECT, 0);
(*f5)(hUrlHandle, buf, 1000, 0);
printf("%s",buf);
InternetCloseHandle(hInternet);
InternetCloseHandle(hUrlHandle);
ret = FreeLibrary(hDll);
The FreeLibrary function takes lots of time in unloading the DLL. This code is running fine on windows XP but on 2000 this is taking too long time & on 98 it is crashing. Can any body help me out y this is happening.
My main concern is if i don't call InternetOpenURL API Freelibrary not take too long time, but if i call this api the FreeLibrary return after very long time.
if you need further detail plz ask me..
thanks,
Manish Birla. Why are loading that dll explicitly???? Why not include the Wininet.lib and call those Win32 Internet Functions from that lib i.e. then you don't need to use that GetProcAddress.
Hope this helps,
Regards,
Usman. thanks usman,
i'm writting a dll which is using wininet.dll. yeah i'm using wininet.lib in that dll. but while i'm unloading my dll it takes too long time. My dll has to loaded & unloaded explicitely.
while debugging i found because of wininet dll my dll taking long time to unload. than i write sample code which i have pasted in my query & run instruction by instruction. I found because of InternetOpenUrl function call it is taking long time. even i closed the handle returned from InternetOpenUrl api call. I'm using wininet sdk for making SSL connection.
I think now u got what is exact problem. Well, he needs to either implicitly or explicitly link to the WinInet library. Why he has chosen the more tedious explicit method I am unsure of, however.
Manish: are you sure it is the FreeLibrary() call causing these problems, or is it something else? The results of toggling InternetOpenUrl() indicates to me that it might be something else causing the slow down. i'm writting a dll which is using wininet.dll. yeah i'm using wininet.lib in that dll. but while i'm unloading my dll it takes too long time. My dll has to loaded & unloaded explicitely.
while debugging i found because of wininet dll my dll taking long time to unload. than i write sample code which i have pasted in my query & run instruction by instruction. I found because of InternetOpenUrl function call it is taking long timeto unload. even i closed the handle returned from InternetOpenUrl api call. I'm using wininet sdk for making SSL connection.
I think now u got what is exact problem. can any body tell me what is problem in sequence of API call. I think the problem is with InternetOpenURL api. but not getting what?? what could be possible error??? i mean weather there is error with sequence of calling the api or error with passing parameters?? I'm closing all handles before unloading properly. is there sth more to do?? If there is problem with parameter it should return error on calling of that particular API but api's r working fine. If i use wininet sdk.lib file this is working fine because i don't need to unload it. but problem is this i can't do.
Is this bug in microsoft wininet sdk itself? If anybody have any idea ab't this problem please let me know. I need to implement HTTPS connection, what is alternate way to do it on windows (98,2000, me &xp all should be supported)..please suggest for any other library or function. I can't use MFC. But i feel MFC classes also internally dependent on WININET sdk only. Please help me... can any body tell me what is problem in sequence of API call. I think the problem is with InternetOpenURL api. but not getting what?? what could be possible error??? i mean weather there is error with sequence of calling the api or error with passing parameters?? I'm closing all handles before unloading properly. is there sth more to do?? If there is problem with parameter it should return error on calling of that particular API but api's r working fine. If i use wininet sdk.lib file this is working fine because i don't need to unload it. but problem is this i can't do.
Is this bug in microsoft wininet sdk itself? If anybody have any idea ab't this problem please let me know. I need to implement HTTPS connection, what is alternate way to do it on windows (98,2000, me &xp all should be supported)..please suggest for any other library or function. I can't use MFC. But i feel MFC classes also internally dependent on WININET sdk only. Please help me... I don't understand why you are implicitly linking to wininet.lib if you are going to explicitly load wininet.dll anyway? That is unnecessary.
Also, is this code from your DllMain function? I hope it's not. as i told my dll is explicitely loaded & unloaded. my dll is using wininet.dll. The problem is while i do freelibrary for my dll it's taking time. To trace out the cause of problem i test it with wininet.dll which my dll is using. so when i unload my dll it might unload wininet dll also. as wininet dll is taking time in unloading in turn my dll also taking long time to unload.
while debugging i trace out the problem. so i wrote separate program to test behavior of wininet at run time. which i have pasted..
again i give u sequence of calling the api's in my dll...
InternetOpen
InternetOpenUrl
HttpQueryInfo
& than closing the handle got from api call InternetOpen & InternetOpenUrl.
While calling this api's r working fine but on unloading it's taking time. On win xp it's working fine.
My dll is using wininet.lib, it is not load it expliciltly. it's just sample program to trace out y my dll is taking too long time while unloading. if i solve out this problem, may be my dll will also unloaded fast.
It is part of big problem to trace out. anyway no where i'm loading or unloading or doing anything with wininet in dll main. In my dll DLL main is doing nothing as far wininet concern. in one function only i'm using wininet dll function to make https connection. my dll is using wininet.lib only but because of some reason my dll taking time to unload. the reason is wininet.lib. if i remove it done very fast.
when i test separately wininet.dll in separate program i found if don't call internetopenurl it unload fast & if i do call it , it takes long time to unload it.
now i think picture is very clear.
manish Hi Manish!
Well I dont know why ur getting this sortof behaviour. I have in my application need to get some data from the HTTPs server. My code looks somewhat like this (For Connecting
Code:
if( !(hInet = InternetOpen(_T("Something"), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 
INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_UI | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_SECURE)))
     return NULL;
if( !(hUrl = InternetOpenUrl(hInet, szUrl, szHeaders, dwSize, INTERNET_FLAG_NO_AUTO_REDIRECT | 
INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_UI | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_SECURE, 0)))
    return NULL;
return hUrl;
and this code to get the Headers of the already opened HTTPs connection
Code:
short CMsnNSock::GetHttpData(HINTERNET hInet, TCHAR *szDataBuffer)
	LPVOID lpOutBuffer = NULL;
	DWORD dwSize = 0;
retry:
	if( !HttpQueryInfo(hInet, HTTP_QUERY_RAW_HEADERS_CRLF, 
(LPVOID)lpOutBuffer, &dwSize, NULL) )
		if (GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND)
			if(lpOutBuffer)
				delete [] lpOutBuffer;			
			return 0;
			if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
				lpOutBuffer	= new TCHAR[dwSize];
				// Retry the call.
				goto retry;				
				if(lpOutBuffer)
					delete [] lpOutBuffer;			
				return 0;
	if( !lpOutBuffer )
		return 0;
	lstrcpy(szDataBuffer, (TCHAR*)lpOutBuffer);
	delete [] lpOutBuffer;
	return 1;
Regards,
Usman. Are you sure you have read ALL data before closing the handle and unloading the library? If not, you may need to wait until the TCP connection times out (FIN_WAIT2). This is neither the problem of HTTP / HTTPS protocol nor the WinInet SDK / API.
Indeed this is a normal behaviour of TCP based communication on most operating systems. * The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform. * Porting from Android to Windows 8: The Real Story
Do you have an Android application? How hard would it really be to port to Windows 8? * Guide to Porting Android Applications to Windows 8
If you've already built for Android, learn what do you really need to know to port your application to Windows Phone 8. * HTML5 Development Center
Our portal for articles, videos, and news on HTML5, CSS3, and JavaScript * Windows App Gallery
See the Windows 8.x apps we've spotlighted or submit your own app to the gallery! Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.