I've got a macro that loads and calls a DLL that I wrote. Until I loaded WP
9 SP4 it worked without a hitch. However after re-loading WP 9 SP4 I am
unable to even compile the macro anymore.
The line it's complianing on is the DLLLoad as follows
DLLName := MacroPath+"LLMMDLL.DLL"
Persist(hInstance)
DLLLoad( hInstance; DLLName)
However when I try to compile it with SP4 installed I get the error:
PerfectScript Compiler - Warning
Description of problem
A 'Warning' was detected during teh compilation of your PerfectScript
macro.
'ModuleInstance' is obsolete or unsupported. See the documentation for a
supported replacement.
Location of Problem
DLLLoad(hInstance; DLLName)
^ (arrow under ; following hInstance)
Check macro file 'llmacros.wcm': line 43, character 19.
With options to "Continue Compilation" or "Cancel Compilation".
What I can't understand is that this with WP 9 SP2 or SP3 this would compile
without error.
I checked the macros help and found the following for DLLLoad
Description
Load a dynamic link library (DLL) into memory.
You should respond to error values with code similar to the following (see
ModuleInstance parameter):
Result := DLLLoad(filename)
Switch(vResult)
CaseOF 0: ...statement block...
CaseOF 2: ...statement block...
EndSwitch
(I'm assuming there's supposed to be a v before Result on the first line but
it's not there in the help...)
This also matches the details given in the printed WP 8 macro manual from
Corel but the manual does at least give a description of the errors
returned...
If the Instance Handle is returned in vResult (from above) HOW do you tell
the difference between an error and a successful load ????
Also - if it's wrong then how come it DID work under WP 9 up to and
including SP 3 ???
Thanks in advance for any help....
-----------[Trevor Campbell]--------------------------------------------
Bekkers IT Perth Western Australia
t...@bekers.com.au
Replies to newsgroup only please unless requested.
Unsolicited e-mails will be deleted without being read.
----------------------------------------------------------------------------
------
using your code
hInstance = DLLLoad( DLLName)
In our case we were loading a registered dll which did not even require a path
like this
kernel32Dll = DllLoad("kernel32")
I had worked out that the syntax had changed (according to the manual but
even the WP8 macro manual says the same thing) but I'm still having problems
actually getting it to work using that syntax.
Can I register my own DLL ? (If so how ?)
If the DLL Load fails for some reason - how do you determine that it's
failed ?
I looked at the help and it says
Return Value
A DLL handle if the DLL successfully loads, or an error value. For example,
31 means a General Failure occurred; 1157 means the DLL was not found.
SO how do you destinguish between a valid DLL Handle & an error value ?
If it's an error is it <= x, but if it's a valid handle then it's > x ? if
so then what is x ?
Thanks
-----------[Trevor Campbell]--------------------------------------------
Bekkers IT Perth Western Australia
t...@bekers.com.au
Replies to newsgroup only please unless requested.
Unsolicited e-mails will be deleted without being read.
----------------------------------------------------------------------------
------
Mark Allred <mal...@utah.uswest.net> wrote in message
news:3A12AE51...@utah.uswest.net...
If the DLLLoad is successfull the returned value will always be a negative
number, so you can use something like the following to test for a successful
load.
hUSER:=DLLLoad("User32")
If(hUSER<0)
MessageBox(; "Error"; "User32.DLL not found -- check the Windows\System
directory to see if the file exists."; OK! | IconStop! | SystemModal!)
Quit
EndIf
I don't know about registering DLLs, but to call them all you have to do is
either put them in the Windows\System directory and the program will
automatically find them, or use the full path to the file in the file name
parameter. For instance if you create a special DLL just for use with a
WordPerfect macro, you may want to put it in your macro folder and call it this
way:
hMY:=DLLLoad(?PathMacros+"my.dll")
Gerald L. Kumpf glk...@aol.com
Corel Solution Partner
Professional Macros for Office Automation
=============================
Ignore my previous message, which I have canceled. The conditional statement in
the code snippet should read "greater than" not "less than." e.g. it should be
If(hUSER>0). My original message, with the above correction made, follows:
That test to confirm Load is what I was looking for.
I am using the full path to Load my DLL as it's in the supplimental macro
directory as it's just for my macros.
Now I'll just need to check my code again....
On the registering side Mark Allred was kind enough to send me the following
directly (Thanks Mark).
I don't actually use VB myself but left that part in for anyone else who
does.
-----Original Message-----
From: Mark Allred [mailto:mal...@uswest.net]
Sent: Friday, 17 November 2000 0:07
To: Trevor Campbell
Subject: Re: Syntax for DLLLoad & DLLCall. Did it change with WP 9 SP 4?????
>try this from within a VB program
>Shell("C:\regsvr32 /s c:\somelocation\Somedll.dll", vbHide)
>
>You can use the same syntax from Run too.
>C:\regsvr32 /s Somedll.dll
>
>if the dll is on the path (something like windows\system32) you don't need
the
>full path
>
>/u will unregister the dll
-----------[Trevor Campbell]--------------------------------------------
Bekkers IT Perth Western Australia
t...@bekers.com.au
Replies to newsgroup only please unless requested.
Unsolicited e-mails will be deleted without being read.
----------------------------------------------------------------------------
------
Gerald L. Kumpf <glk...@aol.com> wrote in message
news:3A13FAE3...@aol.com...
I've just tried modifying my macro to be as shown below:
// Load the External DLL into memory.
// Just to confirm DLL name before Load attempt - YES this is right...
MessageBox( ; "DLL Name="; ">"+DLLName+"<"; IconNone!)
hInstance := DLLLoad( DLLName) // New syntax required by WP 9 SP4
MessageBox( ; "hInstance=" ; ">"+hInstance+"<" ; IconInformation!)
If ( hInstance > 0) // Did the main form get created... if RetValue > 0
means NO
MessageBox( ; "DLL Error" ; "Couldn't Load DLL" ; IconInformation!)
Else // DLL Loaded Just fine
// Check the Version of the DLL by calling standard function
MessageBox( ; "DLL Loaded" ; "Loaded DLL OK...." ; IconInformation!)
EndIf
I put the MessageBox in after the DLL Load to check the value of hInstance
and I'm typically getting numbers like 62652146, 99090432 and similar things
to that - ie: BIG numbers. Then (obviously as this is > 0) I am getting a
DLL Error - Couldn't load DLL...
I then re-named the DLL from the directory and received the error - because
there is not checking to ensure the DLL exists before attempting to load
it....
The Macro is being cancelled because of an error condition processing
product command 'DLLLoad'.
DLLLoad error (Status: 126, Library: 'F:\wpwin\macros.9\WPLinkLL.DLL').
To me the test looks like it would work if hInstance was a typed integer of
the correct precision - but is that possible with WP macros ?
Any ideas ?
As usual, Thanks in advance for any help.
-----------[Trevor Campbell]--------------------------------------------
Bekkers IT Perth Western Australia
t...@bekers.com.au
Replies to newsgroup only please unless requested.
Unsolicited e-mails will be deleted without being read.
----------------------------------------------------------------------------
------
Trevor Campbell <t...@bekkers.com.au> wrote in message news:3a14d6c8@cnews...
If ( hInstance < 256) // Did the main form get created... if RetValue <
256 then it's an error...
I've tested on Win 2000 and it has worked for me so far (only about 1/2
dozen tests...)
I'll test on Win 9x tommorow and report back...
I tried to work out if the return values I was getting were all "signed" 32
bit numbers but they weren't so I couldn't say if they were > 2,147,483,647
(ie: 2^31) then they must be a negative signed 32 bit number... so I just
picked an arbitary (hopefully correct) number (256) and said if it's less
than that it's an error otherwise it's OK...
-----------[Trevor Campbell]--------------------------------------------
Bekkers IT Perth Western Australia
t...@bekers.com.au
Replies to newsgroup only please unless requested.
Unsolicited e-mails will be deleted without being read.
----------------------------------------------------------------------------
------
Trevor Campbell <t...@bekkers.com.au> wrote in message news:3a1b89f2@cnews...