Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用activeX控件";AcroPDF.dll“;我的应用程序工作正常,但如果未安装adobe acrobat,则在启动时崩溃_C#_Winforms_Pdf_Controls_Activex - Fatal编程技术网

C# 使用activeX控件";AcroPDF.dll“;我的应用程序工作正常,但如果未安装adobe acrobat,则在启动时崩溃

C# 使用activeX控件";AcroPDF.dll“;我的应用程序工作正常,但如果未安装adobe acrobat,则在启动时崩溃,c#,winforms,pdf,controls,activex,C#,Winforms,Pdf,Controls,Activex,我有一个向PDF文件添加文本的应用程序,我有一个axAcroPDF1预览面板,它借用acrobat来显示PDF文件的状态,但这不是程序功能所必需的,因此我希望即使未安装acrobat,程序仍能启动,尽管功能更有限,然后用户就不会有一个预览面板,这是很好的。我该怎么做 我唯一想尝试的是在程序启动时,当this.axAcroPDF1正在初始化时添加一个catch/exception,这允许我弹出一条消息,说明需要Adobe reader,但此后程序仍会崩溃,因此我希望程序无论如何都能启动,只是在未安

我有一个向PDF文件添加文本的应用程序,我有一个axAcroPDF1预览面板,它借用acrobat来显示PDF文件的状态,但这不是程序功能所必需的,因此我希望即使未安装acrobat,程序仍能启动,尽管功能更有限,然后用户就不会有一个预览面板,这是很好的。我该怎么做

我唯一想尝试的是在程序启动时,当this.axAcroPDF1正在初始化时添加一个catch/exception,这允许我弹出一条消息,说明需要Adobe reader,但此后程序仍会崩溃,因此我希望程序无论如何都能启动,只是在未安装Adobe时不要调用它,或者你们的任何其他建议,使这个应用程序在使用或不使用adobe的情况下仍然可以运行

我知道如何检查是否安装了adobe,但我不知道如何将结果应用到我的程序中

初始化时的catch异常给出了以下错误(我是noob,所以这里可能没有提供好的信息):



解决方案:我决定使用Inno安装程序,因为我有一些DLL文件,在安装程序脚本中,我会进行adobe检查,如果他们没有adobe或正确的版本,我会提示用户下载reader。以下是检查adobe的基本代码:

    [Code]







 procedure ExitProcess(exitCode:integer);
  external 'ExitProcess@kernel32.dll stdcall'; 

function GetAcrobatReaderVersion(): String;
var
  sVersion:  String;
begin
  sVersion := '';
  RegQueryStringValue( HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe',
     '', sVersion );
  GetVersionNumbersString( sVersion , sVersion );
  Result := sVersion;


end;

function GetAcrobatVersion(): String;
var
  sVersion2: String;
begin


    sVersion2 := '';
  RegQueryStringValue( HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe',
     '', sVersion2 );
  GetVersionNumbersString( sVersion2 , sVersion2 );
  Result := sVersion2;
end;



function NextButtonClick(CurPage: Integer): Boolean;
begin



  // by default go to next page
  Result := true;

  if CurPage = wpWelcome then
  begin

    if Length( GetAcrobatReaderVersion + GetAcrobatVersion() ) = 0 then
    begin
      MsgBox( 'adobe not detected',  mbInformation, MB_OK );

      Result := false;
      ExitProcess(0);//adobe isn't installed, so exit installer
    end

    else
      //MsgBox( 'Acrobat reader installed is version ' + GetAcrobatReaderVersion() ,
      MsgBox( 'adobe detected',  mbInformation, MB_OK );


     end;
  end;

当应用程序崩溃时,是否会触发错误消息或异常?你可以发布关于AxaCropPDF控件使用的代码吗?我没有在没有acrobat的机器上安装c#,但我只是在上面添加了问题签名,我会看看是否可以找到更详细的错误输出。“类未注册”==“acrobat未安装”。嗨,Hans,同意这就是问题所在,但我不确定如何才能使程序仍然启动而不是崩溃,而只保留adobe的功能。
    [Code]







 procedure ExitProcess(exitCode:integer);
  external 'ExitProcess@kernel32.dll stdcall'; 

function GetAcrobatReaderVersion(): String;
var
  sVersion:  String;
begin
  sVersion := '';
  RegQueryStringValue( HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe',
     '', sVersion );
  GetVersionNumbersString( sVersion , sVersion );
  Result := sVersion;


end;

function GetAcrobatVersion(): String;
var
  sVersion2: String;
begin


    sVersion2 := '';
  RegQueryStringValue( HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe',
     '', sVersion2 );
  GetVersionNumbersString( sVersion2 , sVersion2 );
  Result := sVersion2;
end;



function NextButtonClick(CurPage: Integer): Boolean;
begin



  // by default go to next page
  Result := true;

  if CurPage = wpWelcome then
  begin

    if Length( GetAcrobatReaderVersion + GetAcrobatVersion() ) = 0 then
    begin
      MsgBox( 'adobe not detected',  mbInformation, MB_OK );

      Result := false;
      ExitProcess(0);//adobe isn't installed, so exit installer
    end

    else
      //MsgBox( 'Acrobat reader installed is version ' + GetAcrobatReaderVersion() ,
      MsgBox( 'adobe detected',  mbInformation, MB_OK );


     end;
  end;