本文整理汇总了C++中InternetSetOption函数的典型用法代码示例。如果您正苦于以下问题:C++ InternetSetOption函数的具体用法?C++ InternetSetOption怎么用?C++ InternetSetOption使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InternetSetOption函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveConnectionProxy
/**
Set the IE proxy to NULL.
*/
BOOL RemoveConnectionProxy()
{
logger->debug("RemoveConnectionProxy -- START.\n\0");
INTERNET_PER_CONN_OPTION_LIST conn_options;
BOOL bReturn;
DWORD dwBufferSize = sizeof(conn_options);
conn_options.dwSize = dwBufferSize;
conn_options.pszConnection = NULL; //NULL - LAN
conn_options.dwOptionCount = 1;
conn_options.pOptions = new INTERNET_PER_CONN_OPTION[conn_options.dwOptionCount];
conn_options.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
conn_options.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT ;
bReturn = InternetSetOption(NULL,INTERNET_OPTION_PER_CONNECTION_OPTION, &conn_options, dwBufferSize);
delete [] conn_options.pOptions;
InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0);
logger->debug("RemoveConnectionProxy -- OK.\n\0");
return bReturn;
}
示例2: proxy
jboolean proxy(JNIEnv* env, const jobject& jobj, const jstring& proxyStr, const int flags) {
char* proxyAddressStr = jstringToChar(env, proxyStr);
INTERNET_PER_CONN_OPTION_LIST options;
BOOL bReturn;
DWORD dwBufferSize = sizeof(options);
options.dwSize = dwBufferSize;
options.pszConnection = NULL;//connNameStr;//NULL == LAN
options.dwOptionCount = 3;
options.pOptions = new INTERNET_PER_CONN_OPTION[3];
if(!options.pOptions)
return FALSE;
options.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
options.pOptions[0].Value.dwValue = flags;
options.pOptions[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
options.pOptions[1].Value.pszValue = proxyAddressStr;
options.pOptions[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
LPSTR loc = TEXT("local");
options.pOptions[2].Value.pszValue = loc;
bReturn = InternetSetOption(NULL,INTERNET_OPTION_PER_CONNECTION_OPTION, &options, dwBufferSize);
delete [] options.pOptions;
InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0);
delete [] proxyAddressStr;
return bReturn;
}
示例3: SetConnectionProxy
BOOL SetConnectionProxy(char * proxyAdressStr , char * connNameStr = NULL)
{
INTERNET_PER_CONN_OPTION_LIST conn_options;
BOOL bReturn;
DWORD dwBufferSize = sizeof(conn_options);
conn_options.dwSize = dwBufferSize;
conn_options.pszConnection = connNameStr;//NULL == LAN
conn_options.dwOptionCount = 3;
conn_options.pOptions = new INTERNET_PER_CONN_OPTION[3];
if(!conn_options.pOptions)
return FALSE;
conn_options.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
conn_options.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT|PROXY_TYPE_PROXY;
conn_options.pOptions[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
conn_options.pOptions[1].Value.pszValue = proxyAdressStr;
conn_options.pOptions[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
conn_options.pOptions[2].Value.pszValue = "local";
bReturn = InternetSetOption(NULL,INTERNET_OPTION_PER_CONNECTION_OPTION, &conn_options, dwBufferSize);
delete [] conn_options.pOptions;
InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0);
return bReturn;
}
示例4: sizeof
bool BypassHttpProxy::disableProxy()
{
//conn_name: active connection name.
INTERNET_PER_CONN_OPTION_LIST list;
BOOL bReturn;
DWORD dwBufSize = sizeof(list);
// Fill out list struct.
list.dwSize = sizeof(list);
// NULL == LAN, otherwise connectoid name.
list.pszConnection = NULL;
// Set three options.
list.dwOptionCount = 1;
list.pOptions = new INTERNET_PER_CONN_OPTION[list.dwOptionCount];
// Make sure the memory was allocated.
if(NULL == list.pOptions)
{
// Return FALSE if the memory wasn't allocated.
LOG_ERROR("failed to allocat memory in DisableConnectionProxy()");
return false;
}
// Set flags.
list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT ;
// Set the options on the connection.
bReturn = InternetSetOption(NULL,
INTERNET_OPTION_PER_CONNECTION_OPTION, &list, dwBufSize);
// Free the allocated memory.
delete [] list.pOptions;
InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0);
LOG_DEBUG("bReturn=%d", bReturn);
return bReturn;
}
示例5: SetConnectionProxy
/**
Sets the proxy for IE and OS.
*/
BOOL SetConnectionProxy(char * proxyAdressStr , char *bypass)
{
sprintf_s(cbuffer, "SetConnectionProxy -- START:\nproxyAdressStr: '%s'\nbypass: '%s'\n\0", proxyAdressStr, bypass);
logger->debug(cbuffer);
INTERNET_PER_CONN_OPTION_LIST conn_options;
BOOL bReturn;
DWORD dwBufferSize = sizeof(conn_options);
conn_options.dwSize = dwBufferSize;
conn_options.pszConnection = NULL;//NULL == LAN
conn_options.dwOptionCount = 3;
conn_options.pOptions = new INTERNET_PER_CONN_OPTION[3];
conn_options.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
conn_options.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT|PROXY_TYPE_PROXY;
conn_options.pOptions[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
conn_options.pOptions[1].Value.pszValue = proxyAdressStr;
conn_options.pOptions[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
conn_options.pOptions[2].Value.pszValue = bypass;
bReturn = InternetSetOption(NULL,INTERNET_OPTION_PER_CONNECTION_OPTION, &conn_options, dwBufferSize);
delete [] conn_options.pOptions;
InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0);
sprintf_s(cbuffer, "SetConnectionProxy -- OK:\nproxyAdressStr: '%s'\nbypass: '%s'\n\0", proxyAdressStr, bypass);
logger->debug(cbuffer);
return bReturn;
}
示例6: setProxy
BOOL setProxy() {
INTERNET_PER_CONN_OPTION_LIST list;
INTERNET_PER_CONN_OPTION option[3];
unsigned long nSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
option[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
option[0].Value.pszValue = proxyAddress;
option[1].dwOption = INTERNET_PER_CONN_FLAGS;
option[1].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
option[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
option[2].Value.pszValue = L"<local>";
list.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
list.pszConnection = NULL;
list.dwOptionCount = 3;
list.dwOptionError = 0;
list.pOptions = option;
if (!InternetSetOption(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, nSize)) {
return FALSE;
}
if (!InternetSetOption(NULL, INTERNET_OPTION_REFRESH, NULL, 0)) {
return FALSE;
}
return TRUE;
}
示例7: RemoveConnectionProxy
BOOL RemoveConnectionProxy(char* connectionNameStr = NULL)
{
INTERNET_PER_CONN_OPTION_LIST conn_options;
BOOL bReturn;
DWORD dwBufferSize = sizeof(conn_options);
conn_options.dwSize = dwBufferSize;
conn_options.pszConnection = connectionNameStr; //NULL - LAN
conn_options.dwOptionCount = 1;
conn_options.pOptions = new INTERNET_PER_CONN_OPTION[conn_options.dwOptionCount];
if(!conn_options.pOptions)
return FALSE;
conn_options.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
conn_options.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT ;
bReturn = InternetSetOption(NULL,INTERNET_OPTION_PER_CONNECTION_OPTION, &conn_options, dwBufferSize);
delete [] conn_options.pOptions;
InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0);
return bReturn;
}
示例8: setPacFile
jboolean setPacFile(char* proxyAddressStr, const int flags) {
INTERNET_PER_CONN_OPTION_LIST options;
BOOL bReturn;
DWORD dwBufferSize = sizeof(options);
options.dwSize = dwBufferSize;
options.pszConnection = FindActiveConnection();//connNameStr;//NULL == LAN
options.dwOptionCount = 2;
options.pOptions = new INTERNET_PER_CONN_OPTION[2];
if(!options.pOptions) {
return FALSE;
}
options.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
options.pOptions[0].Value.dwValue = flags;
options.pOptions[1].dwOption = INTERNET_PER_CONN_AUTOCONFIG_URL;
options.pOptions[1].Value.pszValue = proxyAddressStr;
//options.pOptions[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
//options.pOptions[2].Value.pszValue = TEXT("local");
bReturn = InternetSetOption(NULL,INTERNET_OPTION_PER_CONNECTION_OPTION, &options, dwBufferSize);
delete [] options.pOptions;
InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0);
return bReturn;
}
示例9: common_delProxy
//取消代理
//返回:true:成功,false:失败
bool common_delProxy()
{
HKEY hKey;
DWORD dwValue=0;
//打开注册表
if (RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", 0, KEY_ALL_ACCESS, &hKey))
{
return false;
}
//设置注册表键值
if (RegSetValueEx(hKey, L"ProxyEnable", 0, REG_DWORD,(LPBYTE)&dwValue, sizeof(DWORD)))
{
RegCloseKey(hKey);
return false;
}
RegCloseKey(hKey);
//发出通知
InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
InternetSetOption(NULL ,INTERNET_OPTION_REFRESH , NULL, 0);
return true;
}
示例10: unsetProxy
BOOL unsetProxy() {
INTERNET_PER_CONN_OPTION_LIST list;
INTERNET_PER_CONN_OPTION option[1];
BOOL bReturn;
DWORD nSize = sizeof(list);
option[0].dwOption = INTERNET_PER_CONN_FLAGS;
option[0].Value.dwValue = PROXY_TYPE_DIRECT;
list.dwSize = sizeof(list);
list.pszConnection = NULL;
list.dwOptionCount = 1;
list.dwOptionError = 0;
list.pOptions = option;
if (!InternetSetOption(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, nSize)) {
return FALSE;
}
if (!InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0)) {
return FALSE;
}
if (!InternetSetOption(NULL, INTERNET_OPTION_REFRESH, NULL, 0)) {
return FALSE;
}
return TRUE;
}
示例11: InternetOpen
BOOL CFtpFile::Connect()
{
HANDLE hThread;
DWORD dwThreadId;
DWORD dwExitCode;
if(m_UserProx == TRUE)
{
m_hHint = InternetOpen(NULL,INTERNET_OPEN_TYPE_PROXY,m_strProx.c_str(),NULL,INTERNET_FLAG_ASYNC);
}
else
{
m_hHint = InternetOpen(NULL,INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,INTERNET_FLAG_ASYNC);
}
long timeout1 = 60000;
long timeout2 = 120000;
InternetSetOption(m_hHint,INTERNET_OPTION_CONNECT_TIMEOUT,(LPVOID)&timeout1,4);
InternetSetOption(m_hHint,INTERNET_OPTION_SEND_TIMEOUT,(LPVOID)&timeout1,4);
InternetSetOption(m_hHint,INTERNET_OPTION_RECEIVE_TIMEOUT,(LPVOID)&timeout2,4);
InternetSetOption(m_hHint,INTERNET_OPTION_DATA_SEND_TIMEOUT,(LPVOID)&timeout1,4);
InternetSetOption(m_hHint,INTERNET_OPTION_DATA_RECEIVE_TIMEOUT,(LPVOID)&timeout2,4);
//wininet的超时设置是无效的,所以下面用线程来实现
hThread = CreateThread(
NULL,
0,
ConnectWork,
this,
0,
&dwThreadId);
//90秒都连接不上,就认为连不上
if(WaitForSingleObject(hThread,90*1000)==WAIT_TIMEOUT)
{
if(m_hHint)
{
InternetCloseHandle(m_hHint);
g_Datalog.Trace(LOGL_TOP,LOGT_WARNING, __TFILE__,__LINE__,_T("WaitTimeout 10s time not connect ftp"));
}
WaitForSingleObject(hThread, INFINITE);
g_Datalog.Trace(LOGL_TOP,LOGT_WARNING, __TFILE__,__LINE__,_T("WaitThread Terminate"));
m_hHint = NULL;
return FALSE;
}
//g_Datalog.Trace(LOGL_TOP,LOGT_PROMPT, __TFILE__,__LINE__, _T("FTP连接完成"));
dwExitCode = 0 ;
GetExitCodeThread(hThread, &dwExitCode);
g_Datalog.Trace(LOGL_TOP,LOGT_PROMPT, __TFILE__,__LINE__, _T("FTP连接完成 exitcode = %d"), dwExitCode);
CloseHandle(hThread);
if(dwExitCode)
{
return FALSE;
}
else
{
return TRUE;
}
}
示例12: togglePac
int togglePac(bool turnOn, const char* pacUrl)
{
int ret = RET_NO_ERROR;
INTERNET_PER_CONN_OPTION_LIST options;
DWORD dwBufferSize = sizeof(options);
options.dwSize = dwBufferSize;
options.pszConnection = FindActiveConnection();
options.dwOptionCount = 2;
options.pOptions = (INTERNET_PER_CONN_OPTION*)calloc(2, sizeof(INTERNET_PER_CONN_OPTION));
if(!options.pOptions) {
return NO_MEMORY;
}
options.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
options.pOptions[1].dwOption = INTERNET_PER_CONN_AUTOCONFIG_URL;
if (turnOn) {
options.pOptions[0].Value.dwValue = PROXY_TYPE_AUTO_PROXY_URL;
wchar_t url[150];
if (swprintf(url, 150, L"%hs", pacUrl) == -1) {
printf("Unable to convert pacUrl to wchar_t %s\n", strerror(errno));
ret = PAC_URL_CONVERSION_ERROR;
goto cleanup;
}
options.pOptions[1].Value.pszValue = (char*)pacUrl;
}
else {
options.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
options.pOptions[1].Value.pszValue = "";
}
BOOL result;
result = InternetSetOption(NULL,INTERNET_OPTION_PER_CONNECTION_OPTION, &options, dwBufferSize);
if (!result) {
reportWindowsError("setting options");
ret = SYSCALL_FAILED;
goto cleanup;
}
result = InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
if (!result) {
reportWindowsError("propagating changes");
ret = SYSCALL_FAILED;
goto cleanup;
}
result = InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0);
if (!result) {
reportWindowsError("refreshing");
ret = SYSCALL_FAILED;
goto cleanup;
}
cleanup:
free(options.pOptions);
return ret;
}
示例13: strUser
STDMETHODIMP CBHttpRequest::setProxyCredentials(BSTR strUserName, BSTR strPassword)
{
CBStringA strUser(strUserName), strPass(strPassword);
if(!InternetSetOption(m_hFile, INTERNET_OPTION_PROXY_USERNAME, (LPSTR)(LPCSTR)strUser, strUser.GetLength() + 1))
return GetErrorResult();
if(!InternetSetOption(m_hFile, INTERNET_OPTION_PROXY_PASSWORD, (LPSTR)(LPCSTR)strPass, strPass.GetLength() + 1))
return GetErrorResult();
return S_OK;
}
示例14: switch
bool Downloader::openInternet()
{
if(internet)
return true; //already opened
#ifdef _DEBUG
_TCHAR *atype;
switch(internetOptions.accessType)
{
case INTERNET_OPEN_TYPE_DIRECT : atype = _T("INTERNET_OPEN_TYPE_DIRECT"); break;
case INTERNET_OPEN_TYPE_PRECONFIG : atype = _T("INTERNET_OPEN_TYPE_PRECONFIG"); break;
case INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY: atype = _T("INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY"); break;
case INTERNET_OPEN_TYPE_PROXY : atype = _T("INTERNET_OPEN_TYPE_PROXY"); break;
default: atype = _T("Unknown (error)!");
}
TRACE(_T("Opening internet..."));
TRACE(_T(" access type: %s"), atype);
TRACE(_T(" proxy name : %s"), internetOptions.proxyName.empty() ? _T("(none)") : internetOptions.proxyName.c_str());
#endif
if(!internet)
if(!(internet = InternetOpen(internetOptions.userAgent.c_str(), internetOptions.accessType,
internetOptions.proxyName.empty() ? NULL : internetOptions.proxyName.c_str(),
NULL, 0)))
return false;
TRACE(_T("Setting timeouts..."));
if(internetOptions.connectTimeout != TIMEOUT_DEFAULT)
InternetSetOption(internet, INTERNET_OPTION_CONNECT_TIMEOUT, &internetOptions.connectTimeout, sizeof(DWORD));
if(internetOptions.sendTimeout != TIMEOUT_DEFAULT)
InternetSetOption(internet, INTERNET_OPTION_SEND_TIMEOUT, &internetOptions.sendTimeout, sizeof(DWORD));
if(internetOptions.receiveTimeout != TIMEOUT_DEFAULT)
InternetSetOption(internet, INTERNET_OPTION_RECEIVE_TIMEOUT, &internetOptions.receiveTimeout, sizeof(DWORD));
#ifdef _DEBUG
DWORD connectTimeout, sendTimeout, receiveTimeout, bufSize = sizeof(DWORD);
InternetQueryOption(internet, INTERNET_OPTION_CONNECT_TIMEOUT, &connectTimeout, &bufSize);
InternetQueryOption(internet, INTERNET_OPTION_SEND_TIMEOUT, &sendTimeout, &bufSize);
InternetQueryOption(internet, INTERNET_OPTION_RECEIVE_TIMEOUT, &receiveTimeout, &bufSize);
TRACE(_T("Internet options:"));
TRACE(_T(" Connect timeout: %d"), connectTimeout);
TRACE(_T(" Send timeout : %d"), sendTimeout);
TRACE(_T(" Receive timeout: %d"), receiveTimeout);
#endif
return true;
}
示例15: GetCSRFToken
//------------------------------------------------------------------------------
void GetCSRFToken(VIRUSTOTAL_STR *vts)
{
HINTERNET M_connexion = 0;
if (!use_other_proxy)M_connexion = InternetOpen("",/*INTERNET_OPEN_TYPE_DIRECT*/INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE);
else M_connexion = InternetOpen("",/*INTERNET_OPEN_TYPE_DIRECT*/INTERNET_OPEN_TYPE_PROXY, proxy_ch_auth, NULL, 0);
if (M_connexion==NULL)M_connexion = InternetOpen("",INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE);
if (M_connexion==NULL)return;
//init connexion
HINTERNET M_session = InternetConnect(M_connexion, "www.virustotal.com",443,"","",INTERNET_SERVICE_HTTP,0,0);
if (M_session==NULL)
{
InternetCloseHandle(M_connexion);
return;
}
//connexion
HINTERNET M_requete = HttpOpenRequest(M_session,"GET","www.virustotal.com",NULL,"",NULL,
INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_SECURE
|INTERNET_FLAG_IGNORE_CERT_CN_INVALID|INTERNET_FLAG_IGNORE_CERT_DATE_INVALID,0);
if (use_proxy_advanced_settings)
{
InternetSetOption(M_requete,INTERNET_OPTION_PROXY_USERNAME,proxy_ch_user,sizeof(proxy_ch_user));
InternetSetOption(M_requete,INTERNET_OPTION_PROXY_PASSWORD,proxy_ch_password,sizeof(proxy_ch_password));
}
if (M_requete==NULL)
{
InternetCloseHandle(M_session);
InternetCloseHandle(M_connexion);
return;
}else if (HttpSendRequest(M_requete, NULL, 0, NULL, 0))
{
//traitement !!!
char buffer[MAX_PATH];
DWORD dwNumberOfBytesRead = MAX_PATH;
if(HttpQueryInfo(M_requete,HTTP_QUERY_SET_COOKIE, buffer, &dwNumberOfBytesRead, 0))
{
if (dwNumberOfBytesRead>42)buffer[42]=0;
//on passe : csrftoken=
strcpy(vts->token,buffer+10);
}
InternetCloseHandle(M_requete);
}
//close
InternetCloseHandle(M_session);
InternetCloseHandle(M_connexion);
}