本帖最后由 小白龙 于 2023-3-15 00:31 编辑
回复 21# went
大佬, 下载后试了一下您的全套, 还是报错, 应该可能是64位dll原因, 我再试下32位的
Exception calling "getPinyin" with "5" argument(s): "试图加载格式不正确的程序。 (异常来自 HRESULT:0x8007000B)"
At C:\Users\Administrator\Desktop\pinyin\test.ps1:17 char:1
+ [Api]::getPinyin($src,$buf,1024,[ref]$len,2)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ( [], MethodInvocationException
+ FullyQualifiedErrorId : BadImageFormatException | cls | | $code=@" | | using System; | | using System.Runtime.InteropServices; | | public static class Api{ | | [DllImport("pinyin.dll")] | | public static extern void getPinyin(byte[] src,byte[] buf,uint max_len,ref uint buf_len,uint mode); | | } | | "@ | | Add-Type -TypeDefinition $code | | | | $s = "中华人民共和国 People's Republic of China" | | | | $src=[System.Text.Encoding]::Default.GetBytes($s) | | $buf = New-Object 'byte[]'(1024) | | $len = 0 | | [Api]::getPinyin($src,$buf,1024,[ref]$len,2) | | | | [System.Text.Encoding]::Default.GetString($buf,0,$len)COPY |
|