Sayfa: [1]   Aşağı git
  Yazdır  
Gönderen Konu: DLL Kaydetme Modülü  (Okunma Sayısı 212 defa)
0 Üye ve 1 Ziyaretçi konuyu incelemekte.
mustibh
Üye
***

Karma: 10
Offline Offline

Cinsiyet: Bay
Mesaj Sayısı: 56



Üyelik Bilgileri WWW
« : 13 Eylül 2008, 15:59:48 »

Öncelikle projemize bir adet modül eklioruz
Daha Sonra




Module Module1
    PrivateDeclare Function LoadLibraryRegister Lib "kernel32" Alias"LoadLibraryA" (ByVal lpLibFileName As String) As Long
    PrivateDeclare Function GetProcAddressRegister Lib "kernel32" Alias"GetProcAddress" (ByVal hModule As Long, ByVal lpProcName As String) AsLong
    Private Declare FunctionCreateThreadForRegister Lib "kernel32" Alias "CreateThread" (ByVallpThreadAttributes As Long, ByVal dwStackSize As Long, ByVallpStartAddress As Long, ByVal lpParameter As Long, ByValdwCreationFlags As Long, ByVal lpThreadID As Long) As Long
    PrivateDeclare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle AsLong, ByVal dwMilliseconds As Long) As Long
    PrivateDeclare Function GetExitCodeThread Lib "kernel32" (ByVal hThread AsLong, ByVal lpExitCode As Long) As Long
    Private Declare Sub ExitThread Lib "kernel32" (ByVal dwExitCode As Long)
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    PrivateDeclare Function FreeLibraryRegister Lib "kernel32" Alias "FreeLibrary"(ByVal hLibModule As Long) As Long
    Dim stFileCouldNotBeLoadedIntoMemorySpace As Integer
    Dim stNotAValidActiveXComponent As Integer
    Dim stActiveXComponentRegistrationFailed As Integer
    Dim stActiveXComponentRegistrationSuccessful As Integer
    Dim stActiveXComponentUnRegisterSuccessful As Integer
    Dim stActiveXComponentUnRegistrationFailed As Integer
    Dim stNoFileProvided As Integer
    Private Const NOERRORS As Long = 0
    Private Const STATUS_WAIT_0 = &H0
    Private Const WAIT_OBJECT_0 = ((STATUS_WAIT_0) + 0)


    Private Enum stRegisterStatus
      stFileCouldNotBeLoadedIntoMemorySpace = 1
      stNotAValidActiveXComponent = 2
      stActiveXComponentRegistrationFailed = 3
      stActiveXComponentRegistrationSuccessful = 4
      stActiveXComponentUnRegisterSuccessful = 5
      stActiveXComponentUnRegistrationFailed = 6
      stNoFileProvided = 7
    End Enum



Public Function Register(ByVal p_sFileName As String) As Object
      Dim lLib As Long
      Dim lProcAddress As Long
      Dim lThreadID As Long
      Dim lSuccess As Long
      Dim lExitCode As Long
      Dim lThreadHandle As Long
      Dim lRet As Long
      On Error GoTo ErrorHandler
      If lRet = NOERRORS Then
        If p_sFileName = "" Then
          lRet = stNoFileProvided
        End If
      End If
      If lRet = NOERRORS Then
        lLib = LoadLibraryRegister(p_sFileName)
        If lLib = 0 Then
          lRet= stFileCouldNotBeLoadedIntoMemorySpace
        End If
      End If
      If lRet = NOERRORS Then
        lProcAddress= GetProcAddressRegister(lLib, "DllRegisterServer")
        If lProcAddress = 0 Then
          lRet= stNotAValidActiveXComponent
        Else
          lThreadHandle= CreateThreadForRegister(0, 0, lProcAddress, 0, 0, lThreadID)
          If lThreadHandle <> 0 Then
            lSuccess= (WaitForSingleObject(lThreadHandle, 10000) = WAIT_OBJECT_0)
            IflSuccess = 0 Then
                CallGetExitCodeThread(lThreadHandle, lExitCode)
                CallExitThread(lExitCode)
                lRet= stActiveXComponentRegistrationFailed
            Else
                lRet= stActiveXComponentRegistrationSuccessful
            End If
          End If
        End If
      End If
ExitRoutine:
      Register = lRet
      If lThreadHandle <> 0 Then
        Call CloseHandle(lThreadHandle)
      End If
      If lLib <> 0 Then
        Call FreeLibraryRegister(lLib)
      End If
      Exit Function
ErrorHandler:
      lRet = Err.Number
      GoTo ExitRoutine
    End Function
End Module


Formun load olayına ,



Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      Dim fileExists As Boolean
      fileExists = My.Computer.FileSystem.FileExists("DLL ismi")
      If fileExists = False Then
        MsgBox("AutoItX3.dllBulunamadı ! ,Bazı programlar doğru çalışmayablir !!!")
      End If
      If fileExists = True Then
        Call Register(CurDir() & "DLL ismi")
      End If
    End Sub
Logged

mustibh
Sayfa: [1]   Yukarı git
  Yazdır  
GoogleTagged

 
Gitmek istediğiniz yer: