首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >inno CreateOleObject unicode

inno CreateOleObject unicode
EN

Stack Overflow用户
提问于 2017-03-08 14:39:03
回答 1查看 757关注 0票数 2

我使用inno的非.net版本将一个工作的unicode dll公开为com对象。它已经运作了很长一段时间,没有任何变化。我正在尝试转换到inno的unicode版本,遇到了一个问题,调用CreateOleObject现在抛出“参数不正确,ProgId:*”

重现这个问题..。

创建一个名为samplecom的C#项目,并在项目属性/程序集信息中将程序集标记为COM-可见

在默认Class1.cs文件中使用以下代码

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace samplecom
{
    [ComVisible(true)]
    public class MyClass
    {
        [ComVisible(true)]
        public string MyMethod()
        {
            return "Hello from COM dll";
        }
    }
}

构建项目,然后从DOS/命令提示符作为管理员使用RegAsm注册dll,注意:下面假设您与dll或samplecom\bin\debug文件夹位于同一个目录中

c:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe samplecom.dll /tlb:samplecom.tlb /codebase

然后使用inno的非unicode和unicode版本使用以下脚本测试

代码语言:javascript
复制
[Setup]
AppName=My Sample COM
AppVersion=1.0
DefaultDirName={pf}\samplecom

[Code]
Var
  comObject: Variant;

function NextButtonClick(CurPage: Integer): Boolean;
var
  hWnd: Integer;
begin
  if CurPage = wpWelcome then begin
    comObject := CreateOleObject('samplecom.MyClass');

    log(comObject.MyMethod());
  end;
  Result := True;
end;

这是inno的ansi版本的输出。

代码语言:javascript
复制
[15:50:23.779]   *** Setup started
[15:50:25.435]   Setup version: Inno Setup version 5.5.8 (a)
[15:50:25.437]   Original Setup EXE: C:\dev\innosandbox\Output\setup.exe
[15:50:25.439]   Setup command line: /SL5="$82622,56832,56832,C:\dev\innosandbox\Output\setup.exe" /SPAWNWND=$92602 /NOTIFYWND=$1A2580 /DEBUGWND=$5310D8 
[15:50:25.440]   Windows version: 10.0.14393  (NT platform: Yes)
[15:50:25.441]   64-bit Windows: Yes
[15:50:25.443]   Processor architecture: x64
[15:50:25.445]   User privileges: Administrative
[15:50:25.446]   64-bit install mode: No
[15:50:25.450]   Created temporary directory: C:\Users\Keith\AppData\Local\Temp\is-E13L9.tmp
[15:50:35.234]   Hello from COM dll

更新: 3/9/2017

这里有一个指向项目的链接以及inno脚本的一个副本.

https://www.dropbox.com/s/nxkwtgm086dtokv/InnoCom.zip?dl=0

我不确定它是相关的还是另一个问题,但使用vbscript/cscript,我可以使用32位vbscript/cscript加载COM对象,但它无法使用64位vbscript/cscript加载

test.vbs文件

代码语言:javascript
复制
Dim objXL
Set objXL = WScript.CreateObject("InnoCom.Inno")
EN

回答 1

Stack Overflow用户

发布于 2020-02-11 09:23:31

Inno安装程序的v6.0.3(u)帮助给出了答案。在"Pascal脚本:使用COM自动化对象“下,“基于IUnknown的COM”上方的一行内容如下:

如果您正在使用.NET COM对象并加载它,则在Inno 5.5.9之后,请尝试在创建COM对象:LoadDLL(ExpandConstant('{sys}\mscoree.dll'), ErrorCode);之前将该行放入脚本中,并添加一个类型为Integer的变量ErrorCode

对我来说,它解决了上面提到的问题。

请参阅scriptautomation.htm

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42674238

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档