我正在使用高级安装程序8.3,并试图为我的应用程序执行试用许可,目标操作系统是Windows7 x32 & x64。
以下代码取自高级安装程序提供的示例。
[DllImport("Trial.dll", EntryPoint = "ReadSettingsStr", CharSet = CharSet.Auto)]
private static extern uint InitTrial(String aKeyCode, IntPtr aHWnd);
[DllImport("Trial.dll", EntryPoint = "ReadSettingsRetStr", CharSet = CharSet.Auto)]
private static extern uint InitTrialReturn(String aKeyCode, IntPtr aHWnd);
[DllImport("Trial.dll", EntryPoint = "DisplayRegistrationStr", CharSet = CharSet.Auto)]
private static extern uint DisplayRegistration(String aKeyCode);
[DllImport("Trial.dll", EntryPoint = "GetPropertyValue", CharSet = CharSet.Auto)]
private static extern uint GetPropertyValue(String aPropName, StringBuilder aResult, ref UInt32 aResultLen);
private void registerToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
Process process = Process.GetCurrentProcess();
DisplayRegistration(kLibraryKey, process.MainWindowHandle);
}
catch(Exception ex1)
{
MessageBox.Show(ex1.ToString());
}
}高级安装程序中的类型签名集是32位unicode DEP感知的。
问题是,每次我选择寄存器时,都会出现访问冲突。似乎我不能使用我的应用程序上的开关关闭DEP,因为它是我的应用程序所需要的。
有没有人有任何想法来绕过这一点,因为我已经检查了高级安装程序论坛,没有什么其他问题,除了类似的问题。
非常感谢
OK快速更新.
我尝试了sig类型的所有组合,这就是我所发现的。
将类型设置为32位Ansi (支持Win9x或更高版本),并将CharSet设置为Ansi/Unicode或自动结果=崩溃。
将类型设置为32位Unicode (DEP感知),并将CharSet设置为Unicode或自动结果=访问冲突。
将类型设置为32位Unicode (DEP感知),并将CharSet设置为Ansi = success。
因此,尽管它正在工作,但在高级安装程序中显然存在一个错误。
发布于 2011-09-05 11:51:15
根据您最近的评论(使用CharSet.None解决了问题),我猜想如下:
指定CharSet.None (这是CharSet.Ansi的代名词)实际上导致了对元帅把弦乐作为ANSI的P/Invoke,而不是Unicode (它将与Windows平台上的CharSet.Auto一起使用)。
从"6.将牌照图书馆纳入申请范围内“的角度看,VB.NET (所以可能也是C#)应该使用Trial.dll (API)的"ANSI“版本。
或者可能有不同版本的Trial.dll支持unicode,但不是在您的路径中(因此P/Invoke找不到)。
我不知道产品,所以很难说。
https://stackoverflow.com/questions/7307158
复制相似问题