DOBON.NETプログラミング道掲示板

ログ内検索
・キーワードを複数指定する場合は 半角スペース で区切ってください。
・検索条件は、(AND)=[A かつ B] (OR)=[A または B] となっています。
・[返信]をクリックすると返信ページへ移動します。 (*過去ログは表示されません)
・過去ログから探す場合は検索範囲から過去ログを選択。
過去ログより前の全過去ログはこちらで検索できます。

キーワード/ 検索条件 /
検索範囲/ 強調表示/ ON (自動リンクOFF)
結果表示件数/ 記事No検索/ ON
投稿日時/ 日以内
大文字と小文字を区別する

No.33353 の関連記事表示

<< 0 >>
■33353  Re[6]: C#で作成したDLLがVB6.0で利用できない
□投稿者/ 魔界の仮面弁士 -(2016/04/30(Sat) 04:02:04)
  • アイコン
    No33349に追記(魔界の仮面弁士の記事)
    > なお、質問内容からは外れてしまいますが、もしもやりたいことが
    > {a5cd92ff-29be-454c-8d04-d82879fb3f1b} の IVirtualDesktopManager を
    > 利用するという点だけなのであれば、C# を介さずに、
    > VB6 や VBA から直接呼び出すという選択肢もあるかも。
    
    
    試しに作ってみました。Form1 からであれば
     Dim c As VirtualDesktopManager
     Set c = New VirtualDesktopManager
     If c.IsVirtualDesktop(Me.hWnd) Then
      MsgBox "OK"
     End If
    のように利用できるはずです。
    (手元に VB6 が無いので、動作検証は 32bit 版の Excel 2016 で行っています)
    
    
    '-----------------------------------------------------------
    'クラスモジュール "VirtualDesktopManager"
    Option Explicit
    
    Private oVirtualDesktopManager As IUnknown
    Private pIVirtualDesktopManager As Long
    
    Private Declare Function IIDFromString Lib "ole32" _
       (ByVal lpsz As Long, _
        ByRef lpiid As Byte) As Long
    
    Private Declare Function StringFromGUID2 Lib "ole32" _
       (ByVal rguid As Long, _
        ByVal lpstrClsId As Long, _
        ByVal cbMax As Integer) As Long
    
    Private Declare Function DispCallFunc Lib "oleaut32" _
       (ByVal pvInstance As Long, _
        ByVal oVft As Long, _
        ByVal cc As Integer, _
        ByVal vtReturn As Integer, _
        ByVal cActuals As Long, _
        ByRef prgvt As Integer, _
        ByRef prgpvarg As Long, _
        ByRef pvargResult As Variant _
    ) As Long
    
    
    Private Sub Class_Initialize()
        Dim iid(0 To 15) As Byte
        Call IIDFromString(StrPtr("{a5cd92ff-29be-454c-8d04-d82879fb3f1b}"), iid(0))
        Set oVirtualDesktopManager = GetObject("new:aa509086-5ca9-4c25-8f95-589d3c07b48a")
        Call Invoke32(ObjPtr(oVirtualDesktopManager), 0, VarPtr(iid(0)), VarPtr(pIVirtualDesktopManager))
    End Sub
    
    Private Sub Class_Terminate()
        Call Invoke32(pIVirtualDesktopManager, 2)
        pIVirtualDesktopManager = 0
        Set oVirtualDesktopManager = Nothing
    End Sub
    
    Private Function Invoke32(ByVal pInstance As Long, ByVal fIdx As Long, ParamArray args() As Variant) As Variant
        Dim l As Long, u As Long, c As Long
        l = LBound(args)
        u = UBound(args)
        c = u - l + 1
    
        Dim vp() As Long
        Dim vt() As Integer
        ReDim vp(IIf(c = 0, l, u))
        ReDim vt(IIf(c = 0, l, u))
    
        Dim i As Long
        For i = l To u
            vt(i) = VarType(args(i))
            vp(i) = VarPtr(args(i))
        Next
    
        Dim hr As Long
        hr = DispCallFunc(pInstance, fIdx * 4, 4, vbLong, c, vt(l), vp(l), Invoke32)
        If hr <> 0 Then
            Err.Raise hr
        End If
    End Function
    
    Public Function IsWindowOnCurrentVirtualDesktop(ByVal topLevelWindow As Long) As Boolean
        Dim outBool As Long
        Dim hr As Long
        hr = CLng(Invoke32(pIVirtualDesktopManager, 3, (topLevelWindow), outBool))
        If hr = 0 Then
            IsWindowOnCurrentVirtualDesktop = CBool(outBool)
        Else
            Err.Raise hr
        End If
    End Function
    
    Public Function GetWindowDesktopId(ByVal topLevelWindow As Long) As String
        Dim hr As Long
        Dim iid() As Byte
        ReDim iid(0 To 15)
        hr = CLng(Invoke32(pIVirtualDesktopManager, 4, (topLevelWindow), iid(0)))
        If hr = 0 Then
            Dim bIID() As Byte
            bIID = String$(40, 0)
            Call StringFromGUID2(VarPtr(iid(0)), VarPtr(bIID(0)), 40)
            GetWindowDesktopId = Left$(UCase(bIID), 38)
        Else
            Err.Raise hr
        End If
    End Function
    
    Public Sub MoveWindowToDesktop(ByVal topLevelWindow As Long, ByVal desktopId As String)
        Dim iid(0 To 15) As Byte
        Call IIDFromString(StrPtr(desktopId), iid(0))
        Dim hr As Long
        hr = CLng(Invoke32(pIVirtualDesktopManager, 5, (topLevelWindow), iid(0)))
        If hr <> 0 Then
            Err.Raise hr
        End If
    End Sub
記事No.33343 のレス /過去ログ1より / 関連記事表示
削除チェック/



<< 0 >>

パスワード/


- Child Tree -