LoadLibrary Issues
LoadLibrary Issues
LoadLibrary Issues
LoadLibrary Issues
LoadLibrary Issues
LoadLibrary Issues LoadLibrary Issues LoadLibrary Issues LoadLibrary Issues LoadLibrary Issues LoadLibrary Issues LoadLibrary Issues LoadLibrary Issues
LoadLibrary Issues LoadLibrary Issues
LoadLibrary Issues
Go Back  Xtreme Visual Basic Talk > > > LoadLibrary Issues


Reply
 
Thread Tools Display Modes
  #1  
Old 03-25-2015, 11:11 PM
fibitini fibitini is offline
Freshman
 
Join Date: Feb 2005
Posts: 33
Default LoadLibrary Issues


i use this code to "load" a OCX in the same folder as the executable.
Code:
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Any, ByVal wParam As Any, ByVal lParam As Any) As Long
Code:
Public Function RegisterServer(hWnd As Long, DllServerPath As String, bRegister As Boolean)
    On Error Resume Next
 
    Dim lb As Long, pa As Long
    lb = LoadLibrary(DllServerPath)

    If bRegister Then pa = GetProcAddress(lb, "DllRegisterServer") Else pa = GetProcAddress(lb, "DllUnregisterServer")
    
    If CallWindowProc(pa, hWnd, ByVal 0&, ByVal 0&, ByVal 0&) = &H0 Then
        MsgBox IIf(bRegister = True, "Registration", "Unregistration") + " Successful"
   Else
        MsgBox IIf(bRegister = True, "Registration", "Unregistration") + " Unsuccessful"
    End If

    FreeLibrary lb
End Function
this code works well in IDE, the OCX is loaded and i can use all the functions from the OCX without issues, but when i compile it and run the executable i get "Unsuccessful". the OCX is in the same folder as the executable. any clue why this behavior?
Reply With Quote
  #2  
Old 03-26-2015, 10:42 AM
dilettante's Avatar
dilettanteLoadLibrary Issues dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

Stop doing this. Create a proper installer.
Reply With Quote
  #3  
Old 03-26-2015, 01:20 PM
fibitini fibitini is offline
Freshman
 
Join Date: Feb 2005
Posts: 33
Default

i know that by registering the OCX/DLL it will put that into the register, the OCX will be available for other applications, at least temporary. even if using DllUnregisterServer, other application will "find".

but, i do not want to create an installation. i want my executable to be portable. and i don't see the dangerous using an unregistered OCX. lots of other programs have drivers that are resident inside the executable folder without needing installation. should that be considered dangerous?

now, my question was not if using unregistered OCX is good or bad, but why the compiled executable don't work.
we have those API for a reason. we should not use them because you think its a "DLL Hell"? well you can think whatever you want, you can make your installation packages, but why should i? if i needed help doing an installation package i would ask that.
Reply With Quote
  #4  
Old 03-27-2015, 05:06 AM
Flyguy's Avatar
FlyguyLoadLibrary Issues Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,164
Default

Have a look here, I think you got your answers and advice already:
http://www.vbforums.com/showthread.p...Library-Issues
Reply With Quote
  #5  
Old 03-29-2015, 07:16 PM
fibitini fibitini is offline
Freshman
 
Join Date: Feb 2005
Posts: 33
Default

just for the purpose to give answer to my question.

to make the registration work you need to run as administrator.
if you want further explanations on the "bad" of doing this way, follow the link Flyguy provided. i came up with a "middle-thing-way" using the approach. maybe not the best but at least its working.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
LoadLibrary Issues
LoadLibrary Issues
LoadLibrary Issues LoadLibrary Issues
LoadLibrary Issues
LoadLibrary Issues
LoadLibrary Issues LoadLibrary Issues LoadLibrary Issues LoadLibrary Issues LoadLibrary Issues LoadLibrary Issues LoadLibrary Issues
LoadLibrary Issues
LoadLibrary Issues
 
LoadLibrary Issues
LoadLibrary Issues
 
-->