zoukankan      html  css  js  c++  java
  • Visual C++ 2011530

    一.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);
    }
    
  • 相关阅读:
    怎么控制 echarts提示框浮层的内容
    控制echarts 柱状图啊的柱条的宽度
    如何控制echartsY轴颠倒
    mac mysql nginx
    input textarea 获取焦点挡住输入法 解决办法
    react 记录
    微信内自动播放audio
    react router
    mysql 记录
    express 插件
  • 原文地址:https://www.cnblogs.com/Clingingboy/p/2081781.html
Copyright © 2011-2022 走看看