views:

36

answers:

3

I'm trying to run some LotusScript code (very similar to Visual Basic) in Lotus Domino on Windows servers.
The code calls some Windows API functions, and works fine on 32-bit Windows 2003 servers, but doesn't work on the one 64-bit server we've tried it on.

Here's one of our external function declarations:

Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" _
(Byval lpFile As String, Byval lpDirectory As String, Byval lpResult As String) As Long

When trying to call that function, LotusScript produces the error message "External function not found".
I have tried both removing the Alias from the declaration, and changing the alias to "FindExecutable" with the same result.

I have also:
- For comparison, tried calling the GetForegroundWindow function in user32.dll - this works.
- Used the Dir function to confirm that shell32 exists with the path "c:\windows\syswow64\shell32.dll", then...
- Changed the Lib in the declaration to the dll's full path - this produces "Error in loading DLL" when calling the function.

Is there anything that must be done differently when calling shell32 functions on a 64-bit server?
Any other reason why the function call would fail on one particular server?

A: 

My guess is that the As Long might be the culprit here - it probably is a bit integer on 32 bit and 64 bit on 64 bit...

Kimvais
If the "As Long" is the problem, then it may not be possible to fix it. LotusScript doesn't have any 64-bit types. Will try the other answer, and hope it works.
Scott Leis
That depends if your script is interpreted in a 64 bit context. If the interpreter itself is a 32 bit application, then it'll use the 32-bit version of shell32.dll, too.
DR
A: 

Did you try using "Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableW" "

Marlon
I've just tried it with the alias "FindExecutableW", and it still says "external function not found".
Scott Leis
Try changing "shell32.dll" with the path to the DLL in the 64bit system.
Marlon
if you explicitly call "C:\Windows\SysWOW64\shell32.dll" it might work since it will load the 32 bit version of it in a 64 bit system. Although I'm curious why WOW didnt take care of that already.
Marlon
A: 

The program executing that script, is that a 64-bit application? If that's the case it is possible that this application cannot load 32-bit DLLs. (That would be the second problem)

To track down the first problem, load shell32.dll explicitly using LoadLibrary (don't use the full path!) and then use GetModuleFileName to get the full file name loaded. There can be all kinds of things responsible for messing with DLL paths. (WOW layer, UAC, path variable, ...)

If that actually works, you can try using Dependency Walker to see if FindExecutable is exported, but I think you'll run into problems before that.

DR
I **think** the program (Lotus Domino 8.5) is 32-bit, but not sure.
Scott Leis
That's the right thing to check, but there's a more powerful way - just use Process Monitor to see where the DLLs get loaded from - you'll easily see if those are 64-bit dlls or 32-bit dlls.
sharptooth
I don't think I have any way to use Process Monitor... is that something in the OS, or a third-party (e.g. SysInternal) program?
Scott Leis
I have no direct access to the OS except what is available through the Domino server.
Scott Leis
@Scott Leis: You'll be much better of if you gain Remote Desktop and run Process Monitor - when an attempt is made to load a library there's a series of filesystem accesses that Process Monitor will show together with the error codes they result in.
sharptooth
@Scott Leis: Yes, Process Monitor is that SysInternals program. It is just great for debugging various cases of using your code from third-party programs.
sharptooth