掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
CreateProcessからのウィンドウのハンドルの取得について (ID:107977)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
今XPとVB6でファイル操作のプログラムを書いているのですが VBからエクスプローラを起動した時にエクスプローラのウィンドウの ハンドルがなぜか取得できません^^; CreateProcessでプロセスを作成し、そのプロセスで EnumWindowsで検索しているのですが、ウィンドウは 作成されているのですが列挙されるプロセスの中に 一致するのがみつからないです。 ためしにエクスプローラではなく、メモ帳でやったところ うまくいったのですが、エクスプローラウィンドウの場合は EnumWindowsでは列挙されないのでしょうか? 参考までに以下にソースを記載します。 よろしくおねがいします Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, lPalam As Long) As Long Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Public m_Handle '取得ハンドル Public Function EnumWindowsProc(ByVal Handle As Long, ByVal lpParam As Long) As Boolean Dim m_Thread As Long Dim m_Process As Long m_Process = 0 'プロセスIDを取得する m_Thread = GetWindowThreadProcessId(Handle, m_Process) If m_Process = lpParam Then m_Handle = Handle EnumWindowsProc = False Exit Function End If EnumWindowsProc = True End Function ------------------------------------------- 一部抜粋 'セキュリティ構造体を初期化 udtProcessAttributes.nLength = Len(udtProcessAttributes) udtThreadAttributes.nLength = Len(udtThreadAttributes) sCurrentDri = vbNullString 'カレントディレクトリを指定 udtStartupInfo.cb = Len(udtStartupInfo) '新しいプロセスのメインウインドウの表示状態を指定 '新しいプロセスの作成 lngResult = CreateProcess(vbNullString, _ "explorer.exe " & sComLine, _ udtProcessAttributes, _ udtThreadAttributes, _ False, _ 0, _ ByVal vbNullString, _ sCurrentDri, _ udtStartupInfo, _ udtProcessInformation) If lngResult <> 0 Then '対象ウインドウのハンドルを検索 Ret = EnumWindows(AddressOf EnumWindowsProc, udtProcessInformation.dwProcessId) -------------------以下省略------------------
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.