⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dllload.cpp

📁 一个WinCE6。0下的IP phone的源代码
💻 CPP
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#include <windows.h>
#include <wininet.h>
#include <urlmon.h>

const WCHAR c_UrlmonLibName[]         = L"Urlmon.dll";
const WCHAR c_WininetLibName[]        = L"Wininet.dll";
const WCHAR c_UrlMkSetSessionOption[] = L"UrlMkSetSessionOption";
const WCHAR c_InternetSetOption[]     = L"InternetSetOption";

typedef HRESULT (WINAPI *pfnUrlMkSetSessionOption)(DWORD, LPVOID, DWORD, DWORD);
typedef HRESULT (WINAPI *pfnInternetSetOption)(HINTERNET, DWORD, LPVOID, DWORD);

class DelayLoad_t
{
public:
    DelayLoad_t()
    {
        m_Wininet = NULL;
        m_Urlmon  = NULL;
    }

    ~DelayLoad_t()
    {
        if (m_Wininet)
        {
            FreeLibrary(m_Wininet);
        }

        if (m_Urlmon)
        {
            FreeLibrary(m_Urlmon);
        }
    }

    HRESULT InternetSetOption(
        HINTERNET hInternet, 
        DWORD dwOption, 
        LPVOID lpBuffer, 
        DWORD dwBufferLength
        )
    {
        if (! m_Wininet)
        {
            m_Wininet = LoadLibrary(c_WininetLibName);
            if (! m_Wininet)
            {
                return E_FAIL;
            }
        }

        pfnInternetSetOption pFn = (pfnInternetSetOption)GetProcAddress(
            m_Urlmon, 
            c_InternetSetOption
            );
        if (! pFn)
        {
            return E_FAIL;
        }

        return (pFn)(hInternet, dwOption, lpBuffer, dwBufferLength);
    }
    
    HRESULT UrlMkSetSessionOption(
        DWORD dwOption, 
        LPVOID pBuffer, 
        DWORD dwBufferLength, 
        DWORD dwReserved
        )
    {
        if (! m_Urlmon)
        {
            m_Urlmon = LoadLibrary(c_UrlmonLibName);
            if (! m_Urlmon)
            {
                return E_FAIL;
            }
        }

        pfnUrlMkSetSessionOption pFn = (pfnUrlMkSetSessionOption)GetProcAddress(
            m_Urlmon, 
            c_UrlMkSetSessionOption
            );
        if (! pFn)
        {
            return E_FAIL;
        }

        return (pFn)(dwOption, pBuffer, dwBufferLength, dwReserved);
    }
    
private:
    HINSTANCE m_Wininet;
    HINSTANCE m_Urlmon;
};

DelayLoad_t g_DelayLoad;

HRESULT Delay_UrlMkSetSessionOption(
    DWORD dwOption, 
    LPVOID pBuffer, 
    DWORD dwBufferLength, 
    DWORD dwReserved
    )
{
    return g_DelayLoad.UrlMkSetSessionOption(dwOption, pBuffer, dwBufferLength, dwReserved);
}

HRESULT Delay_InternetSetOption(
    HINTERNET hInternet, 
    DWORD dwOption, 
    LPVOID lpBuffer, 
    DWORD dwBufferLength
    )
{
    return g_DelayLoad.InternetSetOption(hInternet, dwOption, lpBuffer, dwBufferLength);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -