IStillImage :: RegisterLaunchApplication抛出异常HRESULT:0x8007007B [英] IStillImage::RegisterLaunchApplication throws exception HRESULT: 0x8007007B

查看:212
本文介绍了IStillImage :: RegisterLaunchApplication抛出异常HRESULT:0x8007007B的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在C#2008中开发一个静态图像感应应用程序。当我调用IStillImage :: RegisterLaunchApplication函数时,它会抛出异常HRESULT:0x8007007B(带有描述文件名,目录名或卷标语法不正确) 。
任何人都可以识别代码的问题吗?

系统;
using System.Runtime.InteropServices;
命名空间 WIAtest
{
密封 class StiDeclarations
{
[ DllImport " kernel32.dll" )]
public 静态 extern IntPtr GetModuleHandle( [ MarshalAs UnmanagedType 。LPWStr)] < span style ="font-size:x-small; color:#0000ff"> string lpModuleName); DllImport " sti.dll" )] public 静态 extern IntPtr StiCreateInstance( IntPtr hinst, < span style ="font-size:x-small; color:#0000ff"> int dwVer, out IStillImage ppSti, IntPtr punkOuter);

I'm developing a Still Image aware application in C# 2008. When I call the IStillImage::RegisterLaunchApplication function it throws exception HRESULT: 0x8007007B (with description The filename, directory name, or volume label syntax is incorrect).
Can anyone identify the problem of the code?

System;
using System.Runtime.InteropServices;

namespace 
WIAtest
{
    sealed class StiDeclarations
    {
        [DllImport("kernel32.dll")] 
        public static extern IntPtr GetModuleHandle([MarshalAs(UnmanagedType.LPWStr)] string lpModuleName); DllImport("sti.dll")]
        public static extern IntPtr StiCreateInstance(IntPtr hinst, int dwVer, out IStillImage ppSti, IntPtr punkOuter); 

公开 < span style ="font-size:x-small; color:#0000ff"> const int STI_VERSION = 0x01000002;
公共 const INT STI_VERSION_3 = 0x01000003;
}


[
Guid " 641BD880-2DC8-11D0-90EA-00AA0060F86C" ), InterfaceType ComInterfaceType .InterfaceIsDual)]
公众
界面 IStillImage
{
int RegisterLaunchApplication( MarshalAs UnmanagedType 。LPWStr)] 字符串 pwszAppName,
[
MarshalAs UnmanagedType 。LPWStr)] string pwszCommandLine);
int UnRegisterLaunchApplication( [ < span style ="font-size:x-small; color:#2b91af"> MarshalAs UnmanagedType 。LPWStr)] string pwszCommandLine);


主要功能 -

hinst = < span style ="font-size:x-small; color:#2b91af"> StiDeclarations
。GetModuleHandle( null );
IStillImage sti;
IntPtr ret;
string appname = " ; myapp" ;
string path = " C:\\ Windows \\\\
otepad.exe"
; int ret1;
ret =
StiDeclarations 。StiCreateInstance(hinst, StiDeclarations 。STI_VERSION_3, out sti, IntPtr 。Zero);
ret1 = 0;

          public const int STI_VERSION = 0x01000002; 
        public const int STI_VERSION_3 = 0x01000003;
    }
   
    [
Guid("641BD880-2DC8-11D0-90EA-00AA0060F86C"), InterfaceType(ComInterfaceType.InterfaceIsDual)] 
    public interface IStillImage
    {
        int RegisterLaunchApplication( In, MarshalAs(UnmanagedType.LPWStr)] string pwszAppName,
              [
In, MarshalAs(UnmanagedType.LPWStr)] string pwszCommandLine); 
        int UnRegisterLaunchApplication([In, MarshalAs(UnmanagedType.LPWStr)] string pwszCommandLine);
    }
}


Main function -

hinst = StiDeclarations.GetModuleHandle(null); 
IStillImage sti; 
IntPtr ret; 
string appname = "myapp"; 
string path = "C:\\Windows\\notepad.exe";
int ret1;
ret = 
StiDeclarations.StiCreateInstance(hinst, StiDeclarations.STI_VERSION_3, out sti, IntPtr.Zero);
ret1 = 0;

尝试 {
ret1 = sti .RegisterLaunchApplication(appname,path);
}
catch 例外 e1)
{
MessageBox
。显示(e1.Message + " \ n" + e1.StackTrace);
}

try
{
    ret1 = sti.RegisterLaunchApplication(appname, path);
}
catch (Exception e1)
{
    MessageBox
.Show(e1.Message + "\n" + e1.StackTrace);
}

推荐答案

我在GITHUB上找到了一些解决此问题的代码。

I found some code on GITHUB that resolves this issue.

我遇到了相同的0x8007007B错误。

I was having the same 0x8007007B error.

https://github.com/ryanmcdonnell/ScanToEvernote/blob/c8fd7dfed041950499afe7578700199461a37c65/ScanToEvernote/Program.cs

我认为API调用中的类型可能有问题。

I think maybe something wrong with the types in the API call.





这篇关于IStillImage :: RegisterLaunchApplication抛出异常HRESULT:0x8007007B的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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