Enable 'Allow programaticclipboard access" for IE.

本文介绍了如何使用C++代码通过组策略API为当前用户启用程序化剪贴板访问,并提供了相关的代码示例。

1. for current user. They can simply modify belowregistry.   0=Enable, 1=Prompt

Windows Registry Editor Version 5.00

 

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings\Zones\2]

"1407"=dword:00000000

 

2.Use Group Policy API for all users. Maybe the app need haveAdministrator right.

Policy settings are specified by an administrator. This is incontrast to profile settings, that are specified by a user.

Below is C++ example to enable “'Allow programaticclipboard access

 

#define   INITGUID

#include <Guiddef.h>

 

#include <Prsht.h>

#include <Gpedit.h>

 

#define GPO_IE_REG_ZONE_2_PATH _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\Zones\\2")

 

BOOL SetGroupPolicy(HKEY hKey, LPCTSTR subKey, LPCTSTRvalueName, DWORD dwType, const BYTE* szkeyValue, DWORD dwkeyValue) ;

 

 

int APIENTRY _tWinMain(HINSTANCE hInstance,

                    HINSTANCE hPrevInstance,

                    LPTSTR    lpCmdLine,

                    int       nCmdShow)

{

DWORD dwEnable = 0;

CoInitialize(NULL);

SetGroupPolicy(HKEY_LOCAL_MACHINE,GPO_IE_REG_ZONE_2_PATH,_T("1407"),REG_DWORD,NULL,dwEnable);

              ::CoUninitialize();

              return 0;

}

 

 

BOOL SetGroupPolicy(HKEY hKey, LPCTSTR subKey, LPCTSTRvalueName, DWORD dwType, const BYTE* szkeyValue, DWORD dwkeyValue)

{

    HKEY ghKey, ghSubKey, hSubKey;

    LPDWORD flag = NULL;

    IGroupPolicyObject *pGPO = NULL;

    HRESULT hr =CoCreateInstance(CLSID_GroupPolicyObject, NULL, CLSCTX_ALL,IID_IGroupPolicyObject, (LPVOID*)&pGPO);

 

    if(!SUCCEEDED(hr))

    {

       return FALSE;

    }

 

    if (RegCreateKeyEx(hKey, subKey, 0,NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hSubKey, flag) !=ERROR_SUCCESS)

    {

        return FALSE;

    }

 

    if(dwType == REG_SZ)

    {

        if(RegSetValueEx(hSubKey,valueName, 0, dwType, szkeyValue, strlen((char*)szkeyValue) + 1) !=ERROR_SUCCESS)

        {

            RegCloseKey(hSubKey);

            returnFALSE;

        }

    }

 

    else if(dwType == REG_DWORD)

    {

        if(RegSetValueEx(hSubKey,valueName, 0, dwType, (BYTE*)&dwkeyValue, sizeof(dwkeyValue)) !=ERROR_SUCCESS)

        {

            RegCloseKey(hSubKey);

           returnFALSE;        }

    }

 

    if(!SUCCEEDED(hr))

    {

      return FALSE;

    }

 

    if(pGPO->OpenLocalMachineGPO(GPO_OPEN_LOAD_REGISTRY)!= S_OK)

    {

          returnFALSE;

    }

 

    if(pGPO->GetRegistryKey(GPO_SECTION_USER,&ghKey)!= S_OK)

    {

          returnFALSE;

    }

 

    if(RegCreateKeyEx(ghKey, subKey, 0,NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &ghSubKey, flag) !=ERROR_SUCCESS)

    {

        RegCloseKey(ghKey);

        return FALSE;

    }

 

    if(dwType == REG_SZ)

    {

        if(RegSetValueEx(ghSubKey,valueName, 0, dwType, szkeyValue, strlen((char*)szkeyValue) + 1) !=ERROR_SUCCESS)

        {

            RegCloseKey(ghKey);

            RegCloseKey(ghSubKey);

           returnFALSE;

        }

    }

 

    else if(dwType == REG_DWORD)

    {

        if(RegSetValueEx(ghSubKey,valueName, 0, dwType, (BYTE*)&dwkeyValue, sizeof(dwkeyValue)) !=ERROR_SUCCESS)

        {

            RegCloseKey(ghKey);

            RegCloseKey(ghSubKey);

return FALSE;        }

    }

                GUID RegistryId = REGISTRY_EXTENSION_GUID;

    if(pGPO->Save(false, true,const_cast<GUID*>(&RegistryId),const_cast<GUID*>(&CLSID_GPESnapIn)) != S_OK)

    {

        RegCloseKey(ghKey);

        RegCloseKey(ghSubKey);

return FALSE;

    }

 

    pGPO->Release();

    RegCloseKey(ghKey);

    RegCloseKey(ghSubKey);

    return TRUE;

}

$ ./configure --enable-openssl checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking for cc... cc checking whether the C compiler works... yes checking for C compiler default output file name... a.exe checking for suffix of executables... .exe checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ISO C89... none needed checking how to run the C preprocessor... cc -E checking for icc... no checking for suncc... no checking whether cc understands -c and -o together... yes checking for system library directory... lib checking if compiler supports -R... yes checking build system type... x86_64-pc-cygwin checking host system type... x86_64-pc-cygwin checking target system type... x86_64-pc-cygwin checking for PHP prefix... /usr checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib checking for PHP extension directory... /usr/lib/php/20180731 checking for PHP installed headers prefix... /usr/include/php checking if debug is enabled... no checking if zts is enabled... no checking for re2c... no configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. checking for gawk... gawk checking enable debug log... no checking enable trace log... no checking enable sockets support... no checking enable openssl support... yes checking swoole support... yes, shared checking enable mysqlnd support... no checking enable c-ares support... no checking enable io-uring support... no checking dir of openssl... no checking enable brotli support... auto checking dir of brotli... no checking enable zstd support... no checking dir of nghttp2... no checking enable asan... no checking whether to enable swoole coverage support... no checking whether to enable Swoole developer build flags... no checking whether to enable Swoole CURL build flags... no checking whether to enable postgresql build flags... no checking whether to enable thread context... no checking whether to enable swoole thread support... no checking whether to enable swoole stdext support... no checking whether to enable coroutine execution time ... no checking "for ODBC v3 support for PDO"... no checking if compiling with clang... no checking for cc option to accept ISO C99... none needed ./configure: line 7259: syntax error near unexpected token `CURL,' ./configure: line 7259: ` PKG_CHECK_MODULES(CURL, libcurl >= 7.56.0)'
最新发布
10-21
执行 `./configure --enable-openssl` 时出现 `syntax error near unexpected token 'CURL,'` 和 `PKG_CHECK_MODULES(CURL, libcurl >= 7.56.0)` 错误,通常是由于系统中缺少必要的依赖库或者 `pkg-config` 工具无法正确识别 `libcurl` 库导致的。可以尝试以下解决办法: ### 1. 安装或更新 `pkg-config` `pkg-config` 是一个用于获取库的编译和链接信息的工具,确保它已经正确安装并且是最新版本。 ```bash # 在 Debian 或 Ubuntu 系统上 sudo apt-get update sudo apt-get install pkg-config # 在 CentOS 或 RHEL 系统上 sudo yum install pkg-config ``` ### 2. 安装或更新 `libcurl` 库 确保系统中安装了满足版本要求(`libcurl >= 7.56.0`)的 `libcurl` 库。 ```bash # 在 Debian 或 Ubuntu 系统上 sudo apt-get install libcurl4-openssl-dev # 在 CentOS 或 RHEL 系统上 sudo yum install libcurl-devel ``` ### 3. 检查 `libcurl` 版本 确认系统中安装的 `libcurl` 版本是否满足要求。 ```bash curl --version ``` ### 4. 清理配置文件并重新配置 有时候旧的配置文件可能会导致问题,可以尝试清理配置文件并重新运行 `./configure` 命令。 ```bash make clean ./configure --enable-openssl ``` ### 5. 手动指定 `libcurl` 路径 如果 `pkg-config` 仍然无法正确识别 `libcurl` 库,可以尝试手动指定 `libcurl` 的路径。 ```bash PKG_CONFIG_PATH=/path/to/libcurl/pkgconfig ./configure --enable-openssl ``` 将 `/path/to/libcurl/pkgconfig` 替换为实际的 `libcurl` 库的 `pkgconfig` 文件所在路径。 ### 6. 检查环境变量 确保 `PKG_CONFIG_PATH` 环境变量包含了所有必要的 `pkgconfig` 文件路径。 ```bash echo $PKG_CONFIG_PATH ``` 如果该环境变量为空或者不包含 `libcurl` 的 `pkgconfig` 文件路径,可以添加它。 ```bash export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/path/to/libcurl/pkgconfig ``` 通过以上步骤,应该可以解决执行 `./configure --enable-openssl` 时出现的 `syntax error near unexpected token 'CURL,'` 和 `PKG_CHECK_MODULES(CURL, libcurl >= 7.56.0)` 错误。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值