Jump to content

Register a DLL [resolved]


Recommended Posts

Hi guys and or gals, I have a question. I would first like to say please excuse my frustration, for, I have been trying for [i lost track of how long, many hours stretched over like 2 or 3 days] to get a DLL loaded on WindowsXP. I have searched these forums. I have applied the information that I have found. No go. I have searched the internet. I have applied the information found there. No go. I used google to search these forums. I have tried using Run(), RunWait(), and ShellExecute() combined with all sorts of arcane chants; combinations of magical runes; Baroque dances; Costumes; and dare I say a sacrifice or two in the name of the evil one. I have looked in the helpfile. Please help out an average frustrated chump. I am tyring to use ImageMagick in my script on an xp machine (virtual machine I might add, running on a 64 bit version of Windows7, if that helps) that does not have ImageMagick already installed. Some error messages are as follows (to paraphrase):

"LoadLibrary(imagemagick.dll) failed. the specified module could not be found." "... the application configuration is incorrect ..." et al
Some code snippets that I have tried are as follows:
FileInstall("C:\Program Files (x86)\ImageMagick-6.6.1-Q16\ImageMagickObject.dll", @SystemDir, 0) RunWait("regsvr32 ImageMagickObject.dll", @SystemDir, @SW_HIDE) Run("RegSvr32 ImageMagickObject.dll") $img = ObjCreate("ImageMagickObject.MagickImage.1") RunWait("RegSvr32 ImageMagickObject.dll") $img = ObjCreate("ImageMagickObject.MagickImage.1") ShellExecute("RegSvr32 ImageMagickObject.dll") $img = ObjCreate("ImageMagickObject.MagickImage.1")
I can't think of anymore info that I would need to mention. Begin edit: I have also tried those manifest thingies for the regfreecom or something or another. No joy. End Edit Begin Edit Here's my code:
#include  #include  HotKeySet("{ESC}", "term") Dim $search, $dirStr, $limit = 4, $array0[$limit], $array1[$limit], $img $str = FileOpenDialog("Select from 2 - " & $limit & " jpg images...", "F:", "Jpg (*.jpg;*.jpeg)", 1 + 2 + 4) If @error Then Exit $search = StringSplit($str, "|") $dirStr = $search[1] & '\' _ArrayDelete($search, 1) $imageCount = $search[0] - 1 _ArrayDelete($search, 0) _GDIPlus_Startup() For $i = 0 To UBound($search) - 1    $array0[$i] = _GDIPlus_ImageLoadFromFile($dirStr & $search[$i])     $array1[$i] = _GDIPlus_ImageGetHeight($array0[$i]) Next _GDIPlus_Shutdown() _ArraySort($array1, 0) $resize = $array1[0] _ArrayDelete($array1, 0) ;INSERT DLL REGISTER CODE HERE $img = ObjCreate("ImageMagickObject.MagickImage") DirCreate(@ScriptDir & "\tmp") For $i In $search  $img.Convert($dirStr & $i, "-thumbnail", "x" & $resize, @ScriptDir & "\tmp\" & $i) Next $img.Convert(@ScriptDir & "\tmp\*.jpg", "+append", @ScriptDir & "\panorama.jpg") $img.Convert(@ScriptDir & "\panorama.jpg", "-thumbnail", "715", @ScriptDir & "\panorama.jpg") DirRemove(@ScriptDir & "\tmp", 1) Func term()    Exit EndFunc ;==>term

Edited by jaberwocky6669
Link to comment
Share on other sites

Try this (untested), to register your dll

FileInstall("C:\Program Files (x86)\ImageMagick-6.6.1-Q16\ImageMagickObject.dll", @SystemDir & "\", 0)
$sDll = "ImageMagickObject.dll"
If Not ShellExecute("regsvr32.exe", $sDll, @SystemDir) Then
    MsgBox(262144 + 16, @ScriptName, "Can not register " & $sDll & @TAB)
    Exit
EndIf
$oImg = ObjCreate("ImageMagickObject.MagickImage.1")
If Not IsObj($oImg) Then
    MsgBox(262144 + 16, @ScriptName, "Can not create ImageMagickObject object" & @TAB)
    Exit
EndIf

Edit: message should be "Can not create ImageMagickObject object"

Edited by picaxe
Link to comment
Share on other sites

Try this (untested), to register your dll

FileInstall("C:\Program Files (x86)\ImageMagick-6.6.1-Q16\ImageMagickObject.dll", @SystemDir & "\", 0)
$sDll = "ImageMagickObject.dll"
If Not ShellExecute("regsvr32.exe", $sDll, @SystemDir) Then
    MsgBox(262144 + 16, @ScriptName, "Can not register " & $sDll & @TAB)
    Exit
EndIf
$oImg = ObjCreate("ImageMagickObject.MagickImage.1")
If Not IsObj($oImg) Then
    MsgBox(262144 + 16, @ScriptName, "Can create ImageMagickObject object" & @TAB)
    Exit
EndIf

First I'd like to say that I appreciate that you've taken the time to help.

I ran the script with your code and I get two messages. One message says: "LoadLibrary("ImageMagickObject.dll)" failed. This application failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem." The other message says: "Can create ImageMagickObject object"

I was also able to try it on another XP machine. A similiar message appeared: "LoadLibrary("ImageMagickObject.dll)" failed. A specified module could not be found." The other message was the same: "Can create ImageMagickObject object"

So it appears that your method works as far as being able to register the dll? I no longer get a message about a certain variable having to be of type object!

I also think that there might be an issue with static and dynamic versions of ImageMagick? I think I may have the dynamic installed but I'll check. I have installed both dynamic, static, and earlier versions of IM.

Ok, I just ran this through AutoItDebugger and I got a more detailed error message which suggested that I look at the Application Event Log. So I did and here is what it said: "Activation context generation failed for "C:\Windows\SysWOW64\ImageMagickObject.dll". Dependent Assembly Microsoft.VC90.OpenMP,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis."

Edited by jaberwocky6669
Link to comment
Share on other sites

I finally happened to stumble upon the solution! Here's the code that did the trick:

FileInstall("C:\Program Files (x86)\ImageMagick-6.6.1-Q16\ImageMagickObject.dll", @SystemDir & "\", 1)
RunWait(@ComSpec & " /c /s RegSvr32 """ & @SystemDir & "\ImageMagickObject.dll")

I don't know how this is any different than the countless amount of combinations that I tried, but there ya go.

Link to comment
Share on other sites

Next time try:

$sDll = @SystemDir & "\ImageMagickObject.dll" ; or just name
DllCall($sDll, "long", "DllRegisterServer")

That's how it should be done. You don't need Run, ShellExecute or RegSvr32 or @ComSpec.

It would be worth checking that it succeeded though.

Maybe something like

$sDll = @SystemDir & "\ImageMagickObject.dll" ; or just name
$Res =DllCall($sDll, "long", "DllRegisterServer")
If $Res[0] <> 0 then MsgBox(262144,"ERROR","Failed to register " & $sDll)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

It would be worth checking that it succeeded though.

Maybe something like

$sDll = @SystemDir & "\ImageMagickObject.dll" ; or just name
$Res =DllCall($sDll, "long", "DllRegisterServer")
If $Res[0] <> 0 then MsgBox(262144,"ERROR","Failed to register " & $sDll)

If you want to be that pedantic then it would be:
$sDll = @SystemDir & "\ImageMagickObject.dll" ; or just name
$aCall = DllCall($sDll, "long", "DllRegisterServer")
If @error Or $aCall[0] Then MsgBox(262144, "ERROR", "Failed to register " & FileGetLongName($sDll))

Otherwise you could exit unexpectedly.

He has If Not IsObj($oImg) Then... to check for errors possibly caused by failure to register, after all.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Well, the gods do not look down in me in favor on this day. The exact same code statement that worked so well last night has decided to stop working. So, I tried your solution trancexx. For some reason your code refuses to work. Sheesh, oh well, I'm nothing if not determined.

Link to comment
Share on other sites

Well, the gods do not look down in me in favor on this day. The exact same code statement that worked so well last night has decided to stop working. So, I tried your solution trancexx. For some reason your code refuses to work. Sheesh, oh well, I'm nothing if not determined.

There are two main requirements for every of those methods:

#AutoIt3Wrapper_UseX64=n ; if full SciTE and ImageMagickObject.dll is x86. Otherwise manage yourself.
#RequireAdmin

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

There are two main requirements for every of those methods:

#AutoIt3Wrapper_UseX64=n ; if full SciTE and ImageMagickObject.dll is x86. Otherwise manage yourself.
#RequireAdmin

OK, for some reason or another I uninstalled the static version and installed the dynamic version. I don't remember doing that but I must've. Well, it works once again. #AutoIt3Wrapper_UseX64=n disappears when I compile, is this normal?
Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

  • 2 years later...

Hi all,

I know it's a very old post, but this post is interesting.

I've packaged a registration of 3 OCX files : easy and functionnal.

But, if I want to push my script with sccm for exemple (same way with another tools), the script failed.

The problem is, when the script is started as an "System account", I got an error like "Faulting module name: KERNELBASE.dll.

> If I start the script with an admin accoutn it work

> If I start the script with a system account (with psexec) : ERROR

Do you have an idea about this ?

Thanks,

DraGula

Edited by DraGula
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...