ورود

View Full Version : رجیستر کردن ocx بدون هیچ مشکلی



seyed_27
سه شنبه 09 مهر 1387, 17:15 عصر
یه مشکلی دارم. چطور میشه از اکتیو ایکس فلش استفاده کرد و اون رو در هر ویندوزی رجیستر کرد(در ویندوز هایی که flash8.ocx نداشته باشه) البته رجیستر کردن بدون فایل REGSVR32.EXE
مت این فایل رو به فرم بصورت دستی اضافه میکنم و این برنامه رو با همین فایل رو سیستم های دیگه اجرا میکنم برنامه پیغام میده که این اکتیو ایکس رو پیدا نمی کنم. در ضمن در بعضی از ویندوز ها flash player activx8 رو نصب میکنم یه فایل باید بانام flash8.ocx در شاخه system32\macromed\flash اضاقه بشه ولی نمیشه ویندوز اجازه نمیده فلش پلیرهای دیگه ای رو آزمایش کردم ولی اونا هم نصب نمیشه .
یه راهی برای رجیستر کردن اکتیوایس بدید ممنونم

meys34
چهارشنبه 10 مهر 1387, 22:03 عصر
چه سوال سختي :متفکر:
دليل شما براي استفاده نكردن از Regsvr32.exe چيه؟ بگيد شايد بتونيم كمكتون كنيم.:لبخندساده:

kuh_nur
پنج شنبه 11 مهر 1387, 02:36 صبح
احتمالا نمیخوای رو باز کنی و یا پیغام ثبت می ده اگه اینطوره از این روش استفاده کن
نیازی نیست که همه Activex ها و Dll ها در پوشه System 32 کپی بشن در تو مسیری که اکتیو ایکس رو ریجستر کردی یه نگاهی بندازی یه فایلی همنام اکتیو ایکس با پسوندOCA می بینی که نشان گر مسیر و یک سری از اطلاعات خاص اکتیو ایکسه شما می تونی از این دستور استفاده کنی
shell "regsvr.exe /s Activex Path Acivex Name"
شما میتونی این اکتیو ایکس هارو حتی در مسیر برنامت ریجستر کنی
مثال
shell "regsvr32.exe /s " & App.Path & "\Activex.ocx"

seyed_27
پنج شنبه 11 مهر 1387, 12:32 عصر
جوابشو پیدا کردم یه ماژول خوب دارم :
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)

'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
'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