• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 11 رای - 2.73 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: رجیستر کردن کامپونت ها به روش راحت (ویژوال بیسیک)
حالت موضوعی
#1
با روش زیر میتونید راحت کاپونت هاتون رو رجیستر کنید مثال هم زدم این روش بدون استفاده از Regsvr32.exe هست.

سورس کد :
کد:
'Register Components without using Regsvr32.exe

'NOTE: Check the improved version of this at:


'Before you can use an DLL or an OCX you must register it. Registering a component places information about the control in the system registry. Once the control has been registered, applications and development environments can search the registry to determine which components have been installed.

'Most developers use the Package and deployment wizard to register their components. However, it is occasionally useful to make your own setup kit. The most common method of doing this usually involves shelling Regsvr32.exe. The main problem with shelling Regsvr32.exe is that it is relatively difficult to see if the component was successfully registered.

'The following code shows how to register DLL/Ocx components (including ActiveX EXE's):

Option Explicit

Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lLibFileName As String) As Long
Private Declare Function CreateThread Lib "kernel32" (lThreadAttributes As Any, ByVal lStackSize As Long, ByVal lStartAddress As Long, ByVal larameter As Long, ByVal lCreationFlags As Long, lThreadID As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal lMilliseconds As Long) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lProcName As String) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetExitCodeThread Lib "kernel32" (ByVal hThread As Long, lExitCode As Long) As Long
Private Declare Sub ExitThread Lib "kernel32" (ByVal lExitCode As Long)

'Revisions :    1/Jan/2002. Updated to include code for registering ActiveX Exes.

Function RegisterComponent(ByVal sFilePath As String, Optional bRegister As Boolean = True) As Boolean
    Dim lLibAddress As Long, lProcAddress As Long, lThreadID As Long, lSuccess As Long, lExitCode As Long, lThread As Long
    Dim sRegister As String
    Const clMaxTimeWait As Long = 20000     'Wait 20 secs for register to complete
    
    On Error GoTo ErrFailed
    If Len(sFilePath) > 0 And Len(Dir(sFilePath)) > 0 Then
        'File exists
        If UCase$(Right$(sFilePath, 3)) = "EXE" Then
            'Register/Unregister ActiveX EXE
            If bRegister Then
                'Register EXE
                Shell sFilePath & " /REGSERVER", vbHide
            Else
                'Unregister ActiveX EXE
                Shell sFilePath & " /UNREGSERVER", vbHide
            End If
            RegisterComponent = True
        Else
            'Register/Unregister DLL
            If bRegister Then
                sRegister = "DllRegisterServer"
            Else
                sRegister = "DllUnRegisterServer"
            End If
            
            'Load library into current process
            lLibAddress = LoadLibraryA(sFilePath)
            
            If lLibAddress Then
                'Get address of the DLL function
                lProcAddress = GetProcAddress(lLibAddress, sRegister)
                If lProcAddress Then
                    lThread = CreateThread(ByVal 0&, 0&, ByVal lProcAddress, ByVal 0&, 0&, lThread)
                    If lThread Then
                        'Created thread and wait for it to terminate
                        lSuccess = (WaitForSingleObject(lThread, clMaxTimeWait) = 0)
                        If Not lSuccess Then
                            'Failed to register, close thread
                            Call GetExitCodeThread(lThread, lExitCode)
                            Call ExitThread(lExitCode)
                            RegisterComponent = False
                        Else
                            'Successfully registered component
                            RegisterComponent = True
                            Call CloseHandle(lThread)
                        End If
                    End If
                    Call FreeLibrary(lLibAddress)
                Else
                    'Object doesn't expose OLE interface
                    Call FreeLibrary(lLibAddress)
                End If
            End If
        End If
    End If
    Exit Function

ErrFailed:
    Debug.Print Err.Description
    Debug.Assert False
    On Error GoTo 0
End Function

Private Sub Form_Load()

'Purpose   :    This function registers and Unregisters OLE components
'Inputs    :    sFilePath                       The path to the DLL/OCX or ActiveX EXE
'               bRegister                       If True Registers the control, else unregisters control
'Outputs   :    Returns True if successful
'Notes     :    This is the API equivalent of RegSvr32.exe.
'Example   :
             If RegisterComponent("C:\MyPath\MyFile.dll") = True Then
                 MsgBox "Component Successfully Registered"
             Else
                 MsgBox "Failed to Registered Component"
             End If
End Sub
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
#2
Registering components using regsvr32
رجیستر کردن کامپونت از طریق regsvr32

سورس کد :

کد:
Registering components using regsvr32

Below is a routine for registering components using Regsvr32.exe.

'Purpose     :  Registers components (DLLs and OCXs)
'Inputs      :  sFileName               The path and file name of the component to register.
'               [bUnRegister]           If True unregisters the component, else registers the component.
'               [bHideResults]          If True the confirmation dialog will be hidden, else
'                                       a modal dialog will display the results.
'Outputs     :  N/A


Sub RegisterComponent(sFileName As String, Optional bUnRegister As Boolean = False, Optional bHideResults As Boolean = True)
    If Len(Dir$(sFileName)) = 0 Then
        'File is missing
        MsgBox "Unable to locate file "" & sFileName & """, vbCritical
    Else
        If bUnRegister Then
            'Unregister a component
            If bHideResults Then
                'Hide results
                Shell "regsvr32 /s /u " & """" & sFileName & """"
            Else
                'Show results
                Shell "regsvr32 /u " & """" & sFileName & """"
            End If
        Else
            'Register a component
            If bHideResults Then
                'Hide results
                Shell "regsvr32 /s " & """" & sFileName & """"
            Else
                'Show results
                Shell "regsvr32 " & """" & sFileName & """"
            End If
        End If
    End If
End Sub
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  سورس کدهای ویژوال بیسیک Amin_Mansouri 8 16,562 05-15-2017، 04:35 PM
آخرین ارسال: minarad69
  سورس کد شماره گیری از مودم (ویژوال بیسیک 6 ) Amin_Mansouri 1 6,618 05-07-2017، 06:54 PM
آخرین ارسال: alikorg
  چگونه فایل exe با ویژوال بیسیک بسازیم ؟ Amin_Mansouri 4 13,490 08-13-2015، 10:08 PM
آخرین ارسال: Amin_Mansouri
  مشکل با ارور ویژوال بیسیک aghamali 4 7,028 07-03-2015، 11:14 AM
آخرین ارسال: aaaaaaaaa
  سورس کد کار با وب کم (ویژوال بسیک 6) Amin_Mansouri 1 8,167 04-20-2015، 10:10 PM
آخرین ارسال: hackert41389
  مشکل با paste بیسیک 6 aghamali 1 3,559 01-18-2015، 08:53 PM
آخرین ارسال: aghamali
  فیلتر کردن دیتا گرید aghamali 4 4,984 11-15-2014، 10:50 AM
آخرین ارسال: aghamali
  2 مشکل بیسیک 6 در ویندوز سون aghamali 3 7,062 11-07-2014، 04:25 PM
آخرین ارسال: aghamali
  رجیستر ocx ویندوز سون 32 بیتی aleas 2 4,110 06-02-2014، 02:48 PM
آخرین ارسال: aleas
  جدا کردن حروف عکس aleas 1 3,456 05-29-2014، 11:06 AM
آخرین ارسال: saeedh

پرش به انجمن:


Browsing: 1 مهمان