Vista TaskDialog包装程序:找不到名为';的入口点;间接任务对话框';在DLL';Com

本文关键字:任务 Com DLL 对话框 入口 Vista 程序 包装 找不到 TaskDialog | 更新日期: 2023-09-27 18:21:12

我正在尝试使用Vista TaskDialog包装器和Emulator,但我得到了以下异常:

"在DLL'ComCtl32'中找不到名为'TaskDialogIndirect'的入口点。"

在一个简单的控制台应用程序中:

class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
        PSTaskDialog.cTaskDialog.MessageBox(
            "MessageBox Title",
            "The main instruction text for the message box is shown here.",
            "The content text for the message box is shown here and the text willautomatically wrap as needed.",
            PSTaskDialog.eTaskDialogButtons.YesNo,
            PSTaskDialog.eSysIcons.Information
        );
     }
}

我做错了什么?

更新:

事实上,我正在使用exceldna开发一个Excel插件。如何控制dll Excel加载?

http://exceldna.codeplex.com/discussions/286990#post728888

Vista TaskDialog包装程序:找不到名为';的入口点;间接任务对话框';在DLL';Com

我已经有一段时间没有进行Office编程了,但我的猜测是Excel加载两个版本的comctl32,因此您可能需要使用Activation Context API将代码引导到包含TaskDialog的版本。解决问题的一些想法(不是这样的解决方案):

  • 出于测试目的,对活动进程中的所有模块进行临时枚举,只是为了检查是否真的加载了6.10(参见下面的枚举示例,尽管目的不同)。

  • 使用激活上下文API获取正确的版本。这里是C#的使用示例(用于通过comctl32 6.0启用主题)。

  • 或者(我从来没有在我工作过的WPF应用程序中可靠地工作过),创建一个对话框抽象类,根据可用的版本,它可以回退到MessageDlg。可能有更好的检查方法,但是…:

FileVersionInfo版本=ProcessUtils.GetLoadedModuleVersion("comctl32.dll");if(版本!=null&&版本.FileMajorPart>=6&&版本.FileMinorPart>=1){//我们可以使用TaskDialog。。。}其他的{//使用旧式MessageBox}

模块的枚举:

内部静态FileVersionInfo GetLoadedModuleVersion(字符串名称){Process Process=Process.GetCurrentProcess();foreach(process.Modules中的ProcessModule模块){if(module.ModuleName.ToLower()==name){返回模块。文件版本信息;}返回null;}}

除了其他人所说的:如果将PSTaskDialog上的ForceEmulationMode设置为true,则此错误将消失。