□技術メモ - VB6 起動パラメータ・モジュールパス管理 ※管理人の個人的な技術メモです。このページの内容の実行結果について 管理人はいかなる責任も負いかねますのでご自身の責任でお試しください。 ----------------------------------------------------------- ○VB6における起動パラメータ・モジュールパス管理 CParaMgr.cls -------- Option Explicit '================================= '--> CParaMgr '目的:起動パラメータ・モジュールパス管理 'スプリッタが半角スペースになるのを回避する。 'スプリッタは / とし, パラメータ数は1固定, 両端を""で挟むものとする。 '---- メソッド一覧 'GetUBound 'GetPara 'GetModulePath 'GetModuleDir 'GetModuleName '<-- ここまで '================================= Private para() As String '起動処理 '起動パラメータは1つ持つと想定する。複数の場合は/区切りとする。 Private Sub Class_Initialize() Dim strLine As String strLine = Command() para = Split(strLine, "/") End Sub '終了処理 Private Sub Class_Terminate() ' End Sub 'パラメータ数 Public Function GetUBound() As Integer GetUBound = UBound(para) End Function 'パラメータ取得 Public Function GetPara(i As Integer) As String GetPara = "" If i < 0 Or UBound(para) < i Then Return Else GetPara = para(i) End If End Function 'モジュールパス(フルパス) Public Function GetModulePath() As String GetModulePath = App.Path End Function 'モジュールパス(ディレクトリ, \付き) Public Function GetModuleDir() As String Dim strPath As String Dim iPos As Integer strPath = App.Path iPos = InStrRev(strPath, "\", -1, vbTextCompare) GetModuleDir = Left(strPath, iPos) End Function 'モジュール名 Public Function GetModuleName() As String Dim strPath As String Dim iPos As Integer strPath = App.Path iPos = InStrRev(strPath, "\", -1, vbTextCompare) GetModuleName = Mid(strPath, iPos + 1) End Function --------