c++ - 如何制作 ADUC 属性表 DLL

标签 c++ com active-directory propertysheet

我是一名 Web 开发人员,对 COM 编程的背景了解甚少;我想开发一个属性表以允许另一个部门通过 ADUC 更改缩略图。

到目前为止,我已经制作了所有脚本来注册 DLL 并将其添加到 ADUC,我使用找到的预编译 DLL 对其进行了测试,所以唯一剩下的就是实际制作 DLL 本身。

通过研究,我发现如果我使用 C++,我需要实现 IShellExtInit 和 IShellPropSheetExt 类;我真的很想知道如何在 C# 中做到这一点,但最好先学习更容易的语言,然后我可以尝试自己学习其他语言。

任何人都可以指出一些工作代码示例或教程的方向吗?我所发现的只是更多的理论,而且我从跟随教程中学到了很多东西,所以这将是一个很大的帮助!

到目前为止,我制作了以下 shell 如果它已关闭,请告诉我,但由于我对 COM 的了解有限,到目前为止我只写了这些。

#include "stdafx.h"

#include <ShObjIdl.h>

class PropPage : IShellExtInit, IShellPropSheetExt
{
    /////////////////////////
    //IShellExtInit methods//
    /////////////////////////

    HRESULT Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID)
    {
        return S_OK;
    }

    //////////////////////////////
    //IShellPropSheetExt methods//
    //////////////////////////////

    HRESULT AddPages(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
    {
        return S_OK;
    }

    HRESULT ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam)
    {
        return S_OK;
    }

    /////////////////
    //Misc. methods//
    /////////////////
};

附言当我有更多的时候,我会将它分成一个 cpp 和标题,但是虽然我不知道我在做什么,但将它全部包含在 cpp 中会更容易

最佳答案

The Complete Idiot's Guide to Writing Shell Extensions - Part V解释添加页面,如何将所有内容放在一起并提供引用源代码。

Adding Property Pages

If Initialize() returns S_OK, Explorer queries for a new interface, IShellPropSheetExt. IShellPropSheetExt is quite simple, with only one method that requires an implementation. [...]

The AddPages() method is the one we'll implement. ReplacePage() is only used by extensions that replace pages in Control Panel applets, so we do not need to implement it here. Explorer calls our AddPages() function to let us add pages to the property sheet that Explorer sets up.

The parameters to AddPages() are a function pointer and an LPARAM, both of which are used only by the shell. lpfnAddPageProc points to a function inside the shell that we call to actually add the pages. lParam is some mysterious value that's important to the shell. We don't mess with it, we just pass it right back to the lpfnAddPageProc function.

关于c++ - 如何制作 ADUC 属性表 DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25270653/

相关文章:

powershell - 在 PowerShell 中调用 Get-ADUser 时,如何在过滤条件中转换 AD 属性?

c++ - win32应用程序、windows窗体应用程序和控制台应用程序有什么区别?

c++ - 通过 Visual C++ (API) 访问 Powershell

c++ - #pragma pack 无法编译?

c# - 如何使用 DispId 装饰属性(获取和设置?都不是?)

powershell - 在多个组中使用 Get-ADGroup 和 Get-Groupmember

c++ - Google 基准 while 与 for

c++ - 设置 com 类的数组会触发读取访问

.net - COM 和 .NET 有什么区别?

active-directory - 为什么 Active Directory 中的 DN 使用全名?