文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Visual C++ 2011-5-30

Visual C++ 2011-5-30

时间:2011-06-15  来源:Clingingboy

 

一.UNREFERENCED_PARAMETER的用处

http://blog.csdn.net/liuchanghe/archive/2006/12/31/1471302.aspx

二.RegCopyTree(Windows Vista+)

Copies the specified registry key, along with its values and subkeys, to the specified destination key.


HRESULT CTBSCFCT::CopyRegTree(/*from*/ HKEY hKeyFrom, LPCWSTR lpSubKeyFrom, /*to*/ HKEY hKeyTo, LPCWSTR lpSubKeyTo)
{
    HRESULT hr = S_FALSE;
    HKEY hOpenKeyFrom = NULL,hOpenKeyTo = NULL;
    DWORD dwDisp = 0;
    hr = ::RegCreateKeyEx(hKeyTo,
        lpSubKeyTo,
        0,
        NULL,
        REG_OPTION_NON_VOLATILE,
        KEY_ALL_ACCESS,
        NULL,
        &hOpenKeyTo,
        &dwDisp);
    if( hr != ERROR_SUCCESS)
    {
        hr = E_FAIL;
        goto Exit;
    }

    hr = ::RegOpenKey(hKeyFrom,lpSubKeyFrom,&hOpenKeyFrom);
    if( hr != ERROR_SUCCESS)
    {
        hr = E_FAIL;
        goto Exit;    
    }
    hr = ::RegCopyTree(hOpenKeyFrom,NULL,hOpenKeyTo);
    if( hr != ERROR_SUCCESS)
    {
        hr = E_FAIL;
        goto Exit;
    }

    hr = S_OK;
Exit:
    if(hOpenKeyTo)
    {
        ::RegCloseKey(hOpenKeyTo);
        hOpenKeyTo = NULL;
    }
    if(hOpenKeyFrom)
    {
        ::RegCloseKey(hOpenKeyFrom);
        hOpenKeyFrom = NULL;
    }
    return hr;
}

三. .rgs注册文件

http://blog.csdn.net/idiszerg/archive/2009/02/11/3875934.aspx

四.注册dll

class CAtlSafeArrayModule : public CAtlDllModuleT< CAtlSafeArrayModule >
{
public :
    DECLARE_LIBID(LIBID_AtlSafeArrayLib)
    DECLARE_REGISTRY_APPID_RESOURCEID(IDR_ATLSAFEARRAY, "{623C3042-B3D2-4F3E-856B-CC75B6CF7AF9}")
};

CAtlSafeArrayModule _AtlModule;


// DLL Entry Point
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
    hInstance;
    return _AtlModule.DllMain(dwReason, lpReserved); 
}


// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
    return _AtlModule.DllCanUnloadNow();
}


// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}


// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
    // registers object, typelib and all interfaces in typelib
    HRESULT hr = _AtlModule.DllRegisterServer();
    return hr;
}


// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
    HRESULT hr = _AtlModule.DllUnregisterServer();
    return hr;
}

五.注册Server(.exe)

class CServerDemoModule : public ATL::CAtlExeModuleT< CServerDemoModule >
    {
public :
    DECLARE_LIBID(LIBID_ServerDemoLib)
    DECLARE_REGISTRY_APPID_RESOURCEID(IDR_SERVERDEMO, "{4C612C8F-B76B-423C-B59D-20B6575BA8BD}")
    };

CServerDemoModule _AtlModule;



//
extern "C" int WINAPI _tWinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, 
                                LPTSTR /*lpCmdLine*/, int nShowCmd)
{
    return _AtlModule.WinMain(nShowCmd);
}
相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载