Sign in to follow this  
Followers 0
NerdFencer

Getting an Object from a DLL

10 posts in this topic

I am attempting to get a handle from an object defined in a dll.

I cannot find any information on how to do this...

I have tried

ObjGet("Au3Irr.dll","CAu3Irr")

DllCall("Au3Irr.dll","none","CAu3Irr") ; in hopes of calling the constructor

Does anybody know?


_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Share this post


Link to post
Share on other sites



You need to go thru registration process.

#RequireAdmin

$sDll = "Au3Irr.dll" ; full path

$aCall = DllCall($sDll, "dword", "DllRegisterServer")

If @error Then
    MsgBox(48, "Error", "Failed to register!" & @CRLF & "Error number " & @error)
    Exit
EndIf

If $aCall[0] Then
    MsgBox(48, "Error", "DllRegisterServer failed with error code 0x" & Hex($aCall[0]))
    Exit
EndIf

MsgBox(64, "OK", "DllRegisterServer succeeded!")

$oObj = ObjCreate("CAu3Irr")

If IsObj($oObj) Then
    MsgBox(64, "OK", "Object successfully created!")
Else
    MsgBox(48, "Error", "Object not created!")
EndIf

Exit

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

That's probably the easiest thing to do.

It's all about writing couple of registry keys (and deleting obviously).


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Unfortunately, I don't know exactly what to write...

I have implemented what I know for the script executing the registration...

Here is what I have

#RequireAdmin

RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}","","REG_SZ","Au3Irr 0.1")
RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}\InprocServer32","","REG_SZ",@ScriptDir&"\Au3Irr.dll")
RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}\VersionIndependentProgID","","REG_SZ","CAu3Irr")
RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}\ProgID","","REG_SZ","CAu3Irr")

$sDll = "Au3Irr.dll" ; full path

$oObj = ObjCreate("CAu3Irr")

If IsObj($oObj) Then
    MsgBox(64, "OK", "Object successfully created!")
Else
    MsgBox(48, "Error", "Object not created!")
EndIf

RegDelete("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}")

Exit

Any Ideas on what is going wrong?


_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Share this post


Link to post
Share on other sites

Unfortunately, I don't know exactly what to write...

I have implemented what I know for the script executing the registration...

Here is what I have

#RequireAdmin

RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}","","REG_SZ","Au3Irr 0.1")
RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}\InprocServer32","","REG_SZ",@ScriptDir&"\Au3Irr.dll")
RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}\VersionIndependentProgID","","REG_SZ","CAu3Irr")
RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}\ProgID","","REG_SZ","CAu3Irr")

$sDll = "Au3Irr.dll" ; full path

$oObj = ObjCreate("CAu3Irr")

If IsObj($oObj) Then
    MsgBox(64, "OK", "Object successfully created!")
Else
    MsgBox(48, "Error", "Object not created!")
EndIf

RegDelete("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}")

Exit

Any Ideas on what is going wrong?

Yes. You miss one important registry key.

...I will edit.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Try this.

If it doesn't work then you likely did bad job with dll.

#RequireAdmin
;RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}","","REG_SZ","Au3Irr 0.1")
RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}\InprocServer32", "", "REG_SZ", FileGetLongName(@ScriptDir) & "\Au3Irr.dll")
;RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}\VersionIndependentProgID","","REG_SZ","CAu3Irr")
;RegWrite("HKEY_CLASSES_ROOT\CLSID\{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}\ProgID","","REG_SZ","CAu3Irr")
RegWrite("HKEY_CLASSES_ROOT\CAu3Irr\CLSID", "", "REG_SZ", "{F0BBA28D-6471-4b4e-B7EC-B3B1F082B47A}")


;$sDll = "Au3Irr.dll" ; full path

$oObj = ObjCreate("CAu3Irr")

If IsObj($oObj) Then
    MsgBox(64, "OK", "Object successfully created!")
Else
    MsgBox(48, "Error", "Object not created!")
EndIf

Exit

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I think I messed up with the DLL (its my first time writing a dll)

Once the dll is working, I can put in the functionality I need, but for now, I have the function CreateDevice to use as a test.

Here is my source and project file for the dll (still relatively small).

Can you take a look?

Edited by NerdFencer

_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Share this post


Link to post
Share on other sites

You are confusing.

Go, learn...


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0