表单未显示在凭据提供程序中 [英] Form not displaying in credential provider

查看:83
本文介绍了表单未显示在凭据提供程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中有一个显示表单的函数.我已经使用Unmanaged Exports公开了该函数,并在命令链接上的凭据提供程序示例中从C ++调用了该函数.表单不显示(什么也没有发生).但是,当我使用C ++控制台应用程序调用相同的C#表单时,该表单显示没有任何问题. C ++控制台应用程序正在加载它,而C ++凭据提供程序代码未加载它又有什么区别呢?

I have a function in C# that displays a form. I have exposed the function using Unmanaged Exports and calling it from C++ in credential provider sample on a command link. The form does not display (nothing happens). However, when I call the same C# form using C++ console application, the form displays without any issue. What could be the difference that C++ console application is loading it but C++ credential provider code is not loading it?

C ++代码:

using CSharpForm = void(__stdcall *)(wchar_t* message);
int _tmain(int argc, _TCHAR* argv[])
{
HMODULE mod = LoadLibraryA("CSharp.dll");
CSharpForm form = reinterpret_cast<CSharpForm>(GetProcAddress(mod, "form1"));
form(L"This is a c# form");
getchar();
return 0;
}

C#代码:

[DllExport(ExportName = "form1", CallingConvention = CallingConvention.StdCall)]
public static void showForm([MarshalAs(UnmanagedType.LPWStr)]string message)
{
    Form_Test form = new Form_Test();
    form.Text = message;
    form.ShowDialog();
}

推荐答案

尝试一下:

调用ICredentialProviderCredentialEvents::OnCreatingWindow方法

HRESULT OnCreatingWindow(
    HWND *phwndOwner
);

要获取窗口句柄,请将其他参数传递到您的库中,并使用重载的方法ShowDialog.

to get window handle, pass additional parameter into your library and use overloaded method ShowDialog.

public DialogResult ShowDialog(
    IWin32Window owner
);

这篇关于表单未显示在凭据提供程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆