2

MediaInfo.DLLPascal スクリプトを使用して JPEG 画像と MP4 ビデオ ファイルの情報を取得するために 2 日以上試みています。

しかし、私はエラーが発生し続けます

ランタイム エラー (6:366) - アドレス 0042FD23 でのアクセス違反。アドレス 8065241E の読み取り。

エラーは主に (6:366) を指しています。

を使用してメディア情報を取得しようとしたときに、この例外の原因となっている問題がわかりませんMediaInfo.DLL.

スクリプトに追加したコード:

[Files]
Source: Lamborghini_Aventador.jpg; DestDir: {tmp}; Flags: dontcopy
Source: MediaInfo.dll; DestDir: {tmp}; Flags: dontcopy

[Code]
#ifdef UNICODE
type
  PWideChar = WideString;
#endif

const
  StreamKind_Image = 5;
  InfoKind_Text = 1;

function MediaInfo_New: Cardinal;
  external 'MediaInfo_New@{tmp}\MediaInfo.dll stdcall delayload';
function MediaInfo_Open(Handle: Cardinal; File__: PWideChar): Boolean;
  external 'MediaInfo_Open@{tmp}\MediaInfo.dll stdcall delayload';
function MediaInfo_Get(Handle: Cardinal; StreamKind: Integer; StreamNumber: Integer; Parameter: PWideChar; KindOfInfo: Integer; KindOfSearch: Integer): PWideChar;
  external 'MediaInfo_Get@{tmp}\MediaInfo.dll stdcall delayload';

procedure RetrieveImageInformation;
var
  IHandle: Cardinal;
  Width: PWideChar;
begin
  ExtractTemporaryFile('Lamborghini_Aventador.jpg');
  ExtractTemporaryFile('MediaInfo.dll');
  IHandle := MediaInfo_New();
  MediaInfo_Open(IHandle, PWideChar(ExpandConstant('{tmp}\Lamborghini_Aventador.jpg')));
  Width := MediaInfo_Get(IHandle, StreamKind_Image, 0, 'Width', InfoKind_Text, 0);
  Log('Width of the JPEG Image: ' + PWideChar(Width) + '.');
end;

例外が生成されている行は次のとおりです。

Width := MediaInfo_Get(IHandle, StreamKind_Image, 0, 'Width', InfoKind_Text, 0);

コンパイラの出力は次のようになると予想していましたWidth of the JPEG Image: 1920.

最新バージョンの Unicode Inno Setup Compiler (5.5.9 - U) を使用しています

あなたの重要な助けを前もって感謝します。

4

2 に答える 2

2

Inno Setup Pascal Script から文字列 (文字バッファー) へのポインターを返す関数を呼び出すことはできないと思います。

しかし、次のようにハックできます。

  • を返すかのように関数を宣言しますCardinal
  • ポインターを受け取り、それを別のポインターにコピーする利用可能な関数を使用します。ソース ポインターを として宣言しCardinal、ターゲット ポインターをとして宣言しますstring。そのような関数の 1 つがStrCpyN.
function MediaInfo_Get(
  Handle: Cardinal; StreamKind: Integer; StreamNumber: Integer;
  Parameter: string; KindOfInfo: Integer; KindOfSearch: Integer): Cardinal;
  external 'MediaInfo_Get@{tmp}\MediaInfo.dll stdcall delayload';

function StrCpyN(S1: string; S2: Cardinal; Max: Cardinal): Cardinal;
  external 'StrCpyNW@shlwapi.dll stdcall';
var
  P: Cardinal;
  S: string;
begin
  P := MediaInfo_Get(IHandle, StreamKind_Image, 0, 'Width', InfoKind_Text, InfoKind_Name);
  S := StringOfChar(' ', 1024);
  StrCpyN(S, P, Length(S) - 1);
  S := Trim(S);
  ...
end;

このコードにはUnicode Inno Setup (Inno Setpu 6 以降の唯一のバージョン) が必要です。

于 2016-08-28T15:21:34.803 に答える
1

MediaInfo Command Line InterfaceInno Setup Ansi または Unicode バージョンで使用できます。

使用例:

[Files]
Source: MediaInfo.exe; DestDir: {tmp}; Flags: Dontcopy

[code]
function InitializeSetup(): Boolean;
var
   ErrorCode: Integer;
begin
   ExtractTemporaryFile('MediaInfo.exe');
   ShellExec('Open', 'MediaInfo.exe', ExpandConstant('"YourFileName.mp4" --LogFile="YourFileName Prperties.log"'), ExpandConstant('{tmp}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode);
   if SysErrorMessage(DLLGetLastError) = SysErrorMessage(0) then
   Result := True;  
end;

ここで、Run (Windows キー + R) コマンドを使用して管理者として Inno Setup 一時ディレクトリに移動し、コマンドで指定したファイルに関する情報を含むメディア情報ログ ファイルが存在することを確認します。

于 2016-08-23T01:43:55.203 に答える