Q&A

  • 베이직넷으로된 소소를 델파이 DLL로 만드는 방법이나 힌트 ..
MSDN을 참고해서 베이직.net으로 dll 코드를 기존에 만들어 두었습니다.
이번에 델파이로 변환하는 작업를 하며 나름대로 공부를 하고 있는 중입니다. 제가 아직 델파이에 미숙한 점이 많아서 변환하는데 상당한 어려움을 겪고 있습니다.

지금 제가 만들어 놓은 베이직 소소를 올립니다.

부디 여러분들의 많은 도움 부탁드리겠습니다. ㅡㅡ;

<!--CodeS-->

Imports System
Imports System.Runtime.InteropServices
Imports Microsoft.WindowsMediaServices.Interop
Imports Microsoft.Win32

<GuidAttribute("7DF709B2-3585-4201-BC50-4820ABE2BF18")> _
Public Class VBEventTest
    Implements IWMSBasicPlugin
    Implements IWMSEventNotificationPlugin

    Public Sub EnablePlugin( _
            ByRef plFlags As Integer, _
            ByRef plHeartbeatPeriod As Integer) _
                  Implements IWMSBasicPlugin.EnablePlugin

        ' Set the heartbeat period to zero.
        plFlags = 0
        plHeartbeatPeriod = 0
    End Sub

    Public Sub DisablePlugin() _
                  Implements IWMSBasicPlugin.DisablePlugin

    End Sub

    Public Sub InitializePlugin( _
            ByVal pServerContext As IWMSContext, _
            ByVal pNamedValues As WMSNamedValues, _
            ByVal pClassFactory As IWMSClassObject) _
                  Implements IWMSBasicPlugin.InitializePlugin

    End Sub

    Public Sub OnHeartBeat() _
                  Implements IWMSBasicPlugin.OnHeartbeat

    End Sub

    Public Sub ShutDownPlugin() _
                  Implements IWMSBasicPlugin.ShutdownPlugin

    End Sub

    Public Function GetCustomAdminInterface() As Object _
                  Implements IWMSBasicPlugin.GetCustomAdminInterface
        Return 0
    End Function


    Public Function GetHandledEvents() As Object _
                   Implements IWMSEventNotificationPlugin.GetHandledEvents

        ' Capture the connect and disconnect events.
        Dim iHandledEvents(2) As Integer
        iHandledEvents(0) = WMS_EVENT_TYPE.WMS_EVENT_CONNECT
        iHandledEvents(1) = WMS_EVENT_TYPE.WMS_EVENT_DISCONNECT

        Return iHandledEvents

    End Function

    Public Sub OnEvent( _
              ByRef pEvent As WMS_EVENT, _
              ByVal pUserCtx As IWMSContext, _
              ByVal pPresentationContext As IWMSContext, _
              ByVal pCommandCtx As IWMSCommandContext) _
                      Implements IWMSEventNotificationPlugin.OnEvent

        Try
            Select Case pEvent.Type
                Case WMS_EVENT_TYPE.WMS_EVENT_CONNECT
                    MsgBox("Client connected", _
                           MsgBoxStyle.OKOnly, _
                           "VB Sample Event Plug-in")

                Case WMS_EVENT_TYPE.WMS_EVENT_DISCONNECT
                    MsgBox("Client disconnected", _
                           MsgBoxStyle.OKOnly, _
                           "VB Sample Event Plug-in")
            End Select

        Catch e As Exception
            MsgBox(e.ToString, MsgBoxStyle.OKOnly, "OnEvent Error")

        End Try

    End Sub


    '레지스트리 등록
    <ComRegisterFunctionAttribute()> _
    Shared Sub RegisterFunction(ByVal t As Type)
        Try
            Dim regHKLM As RegistryKey
            regHKLM = Registry.LocalMachine
            regHKLM = regHKLM.CreateSubKey("SOFTWARE\\Microsoft\\Windows Media\\Server\\RegisteredPlugins\\Event Notification and Authorization\\{7DF709B2-3585-4201-BC50-4820ABE2BF18}")
            regHKLM.SetValue(Nothing, "Sample VBEvent Notification1")

            Dim regHKCR As RegistryKey
            regHKCR = Registry.ClassesRoot
            regHKCR = regHKCR.CreateSubKey("CLSID\\{7DF709B2-3585-4201-BC50-4820ABE2BF18}\\Properties")
            regHKCR.SetValue("Name", "Sample VBEvent Notification")
            regHKCR.SetValue("Author", "ABCXYZ Corporation")
            regHKCR.SetValue("CopyRight", "Copyright 2002 . All rights reserved")
            regHKCR.SetValue("Description", "Enables you to trap the connect and disconnect events")

        Catch e As Exception
            MsgBox(e.Message, MsgBoxStyle.OKOnly)
        End Try
    End Sub


    '레지스트리 등록
    <ComUnregisterFunction()> _
      Shared Sub UnRegisterFunction(ByVal t As Type)
        Try

            Dim regHKLM As RegistryKey
            regHKLM = Registry.LocalMachine
            regHKLM.DeleteSubKey("SOFTWARE\\Microsoft\\Windows Media\\Server\\RegisteredPlugins\\Event Notification and Authorization\\{7DF709B2-3585-4201-BC50-4820ABE2BF18}")

            Dim regHKCR As RegistryKey
            regHKCR = Registry.ClassesRoot
            regHKCR.DeleteSubKeyTree("CLSID\\{7DF709B2-3585-4201-BC50-4820ABE2BF18}")
            regHKCR.DeleteSubKeyTree("VBEventTest.VBEventPlugin")

        Catch e As Exception
            MsgBox(e.Message, MsgBoxStyle.OKOnly)
        End Try
    End Sub

End Class

<!--CodeE-->
0  COMMENTS