掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
vb.net 2003 7-zip32.dllの呼び出だしについて (ID:141426)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
http://dobon.net/vb/dotnet/links/extractarchive.html 上記を元に7-zipに置き換えてみたのですが、 ========================================== 'DLLをロード Dim hmod As Integer = LoadLibrary(dllName) エラー:'System.DllNotFoundException' のハンドルされていない例外が XXXX.exe で発生しました。 追加情報 : DLL (7-zip32) を読み込めません。 ========================================== のエラーが出てしまいます。 下記のコードが7-zipに置き換えたかたちなのですが、 ========================================== Imports System.Runtime.InteropServices Imports System.Text Public Class SevenZip 'セブンジップ圧縮設定DLL <DllImport("7-zip32")> _ Private Function SevenZip(ByVal hwnd As Integer, ByVal szCmdLine As String, ByVal szOutput As String, ByVal dwsize As Integer) End Function <DllImport("7-zip32")> _ Private Shared Function LoadLibrary( _ ByVal lpLibFileName As String) As Integer End Function 'マップを解除 <DllImport("7-zip32")> _ Private Shared Function FreeLibrary( _ ByVal hLibModule As Integer) As Boolean End Function '関数のアドレスを取得 <DllImport("7-zip32")> _ Private Shared Function GetProcAddress( _ ByVal hModule As Integer, ByVal lpProcName As String) As Integer End Function '以下使用するAPIのためのInvokeFunc <DllImport("Invoke", EntryPoint:="InvokeFunc")> _ Private Shared Function InvokeGetVersion( _ ByVal funcptr As Integer) As UInt16 End Function <DllImport("Invoke", EntryPoint:="InvokeFunc")> _ Private Shared Function InvokeGetRunning( _ ByVal funcptr As Integer) As Boolean End Function <DllImport("Invoke", EntryPoint:="InvokeFunc")> _ Private Shared Function InvokeCheckArchive( _ ByVal funcptr As Integer, _ ByVal szFileName As String, _ ByVal iMode As Integer) As Boolean End Function <DllImport("Invoke", EntryPoint:="InvokeFunc")> _ Private Shared Function InvokeMain( _ ByVal funcptr As Integer, _ ByVal hwnd As Integer, _ ByVal szCmdLine As String, _ ByVal szOutput As String, _ ByVal dwSize As Integer) As Integer End Function ''' <summary> ''' 統合アーカイバ仕様のDLLで書庫を展開する ''' </summary> ''' <param name="dllName">DLLファイル名</param> ''' <param name="funcName">APIの頭に付く文字列</param> ''' <param name="command">展開のためのコマンド</param> ''' <param name="archiveFile">書庫ファイル名</param> ''' <param name="extractDir">展開先のフォルダ名</param> Public Shared Sub ExtractArchive_7z( _ ByVal dllName As String, _ ByVal funcName As String, _ ByVal command As String, _ ByVal archiveFile As String, _ ByVal extractDir As String) '指定されたファイルがあるか調べる If Not System.IO.File.Exists(archiveFile) Then Throw New ApplicationException("ファイルが見つかりません") End If 'DLLをロード Dim hmod As Integer = LoadLibrary(dllName) If hmod = 0 Then Throw New ApplicationException( _ dllName + "のロードに失敗しました") End If Try Dim funcaddr As Integer 'DLLのチェック '関数のアドレスを取得 funcaddr = GetProcAddress(hmod, funcName + "GetVersion") If funcaddr = 0 Then Throw New ApplicationException( _ dllName + "がインストールされていません") End If Dim ver As UInt16 = InvokeGetVersion(funcaddr) Console.WriteLine("バージョン:{0}", ver) '動作中かチェック funcaddr = GetProcAddress(hmod, funcName + "GetRunning") If funcaddr = 0 Then Throw New ApplicationException( _ funcName + "GetRunningのアドレスが取得できませんでした") End If If InvokeGetRunning(funcaddr) Then Throw New ApplicationException(dllName + "が動作中") End If '展開できるかチェック funcaddr = GetProcAddress(hmod, funcName + "CheckArchive") If funcaddr = 0 Then Throw New ApplicationException( _ funcName + "CheckArchiveのアドレスが取得できませんでした") End If If Not InvokeCheckArchive(funcaddr, archiveFile, 0) Then Throw New ApplicationException( _ archiveFile + "は対応書庫ではありません") End If 'ファイル名とフォルダ名を修正する If archiveFile.IndexOf(" "c) > 0 Then archiveFile = """" + archiveFile + """" End If If Not extractDir.EndsWith("\") Then extractDir += "\" End If If extractDir.IndexOf(" "c) > 0 Then extractDir = """" + extractDir + """" End If '展開する funcaddr = GetProcAddress(hmod, funcName) If funcaddr = 0 Then Throw New ApplicationException( _ funcName + "のアドレスが取得できませんでした") End If Dim ret As Integer = InvokeMain(funcaddr, 0, _ String.Format(command, archiveFile, extractDir), _ Nothing, 0) '結果 If ret <> 0 Then Throw New ApplicationException("書庫の展開に失敗しました") End If Finally '開放する If hmod <> 0 Then FreeLibrary(hmod) End If End Try End Sub End Class
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.