#include <stdio.h>
#include <windows.h>
#include <winhttp.h>
#pragma comment(lib, "winhttp")
struct callback_param_t
{
HINTERNET hInet;
DWORD dwErrCert;
};
static VOID CALLBACK SyncCallback(HINTERNET, DWORD_PTR, DWORD, PVOID, DWORD);
DWORD ConnectHTTPSFunc(LPCWSTR pswzServerName,LPCWSTR pswzObjectName,LPDWORD lpdwErrCert)
{
DWORD dwErr = ERROR_SUCCESS;
HINTERNET hSession = NULL;
HINTERNET hConnect = NULL;
HINTERNET hRequest = NULL;
if(NULL == lpdwErrCert)
{
*lpdwErrCert = 0;
}
hSession = ::WinHttpOpen(0,WINHTTP_ACCESS_TYPE_NO_PROXY,WINHTTP_NO_PROXY_NAME,WINHTTP_NO_PROXY_BYPASS,0);
if(NULL == hSession)
{
dwErr = ::GetLastError();
}
else
{
///
hConnect = ::WinHttpConnect(hSession,pswzServerName,INTERNET_DEFAULT_HTTPS_PORT,0);
if(NULL == hConnect)
{
dwErr = ::GetLastError();
}
else
{
// Use WINHTTP_FLAG_SECURE flag to verify CRL