Progress / Windows XP COM-handle respectively dll

Hello,
I use a dll as com-handle in Progress:
My (second) Problem is the following:
The dll gives me an error code, but I am not able to receive this error number. I only receive from Progress the information wether the method was successfully or not.
In Visual Basic it is possible to work with the 'errorhandler' and the object 'err' an to receveive the error nummer of a called dll.
Is this also possible in Progress?
Does anyone has an Idea?
 
Look at API call GetLastError:

(From KB entry 17655 I can't find online)


How to Call WIN32 API Function: GetLastError

DISCLAIMER:
===========
The code example in this knowledgebase is for informational purposes
only. If you have specific questions about which API calls would be
best suited to your design goals, please consult your Microsoft
documentation.

INTRODUCTION:
=============
The following sample code shows how to call the Win32 API function
called GetLastError. This function returns the last error set by
the system in the thread's local storage area. GetLastError() is
thread dependent, which means errors will not be shared among threads
of a process. Please note that due to a bug, this API call will only
work in Progress Versions 9.0B and later. All other versions will
always return a value of 127.

This code has been tested on Windows NT 4.0 Workstation only.


DEFINE VARIABLE intResult AS INTEGER NO-UNDO.

PROCEDURE GetLastError EXTERNAL "KERNEL32.DLL":
DEFINE RETURN PARAMETER intResult AS LONG.
END PROCEDURE.

RUN GetLastError (OUTPUT intResult).

MESSAGE "Last API Error = " intResult VIEW-AS ALERT-BOX.

Lee
 
Hello,
the 'Get Last Error' alone does not work because I always get an Api Error 0 (see the code), so I will try it with the second tip (FormatMessageA).
DEFINE VARIABLE vc-qo AS CHAR NO-UNDO INIT "qo1":U.
DEFINE VARIABLE intResult AS INTEGER NO-UNDO.
vh-qotrans:qoconntest(INPUT-OUTPUT gc-qo) NO-ERROR.
RUN GetLastError (OUTPUT intResult).
MESSAGE "Last API Error = " intResult VIEW-AS ALERT-BOX.
MESSAGE ERROR-STATUS:GET-NUMBER(1)SKIP ERROR-STATUS:GET-MESSAGE(1).
vh-qotrans is my com-handle.
qoconntest is the method.

M. Röttgermann
 
Hello,
the function 'FormatMessageA' works well.
It gives me really the message text of an error get before by the API 'GetLAstError'. So as an information for you: This is okay,
BUT:
my problem is that I don't get an error nummer by calling 'GetLastError'. I receveive all the time a '0'. Probably this API does not work because our com-handle is not a Windows API? It is a own written dll.
If you have another Idea please tell it to me.
Matthias
 
roettgermann said:
my problem is that I don't get an error nummer by calling 'GetLastError'. I receveive all the time a '0'. Probably this API does not work because our com-handle is not a Windows API? It is a own written dll.

Yes, I think you are right.

You want an equivalent of Err.LastDLLError. I don't know of any Win32 api equivalent.

There is an equivalent .Net call (GetLastWin32Error), but I wouldn't know how to make use of this from the 4GL. Perhaps someone here with .Net experience can advise.

Apologies for the Red Herring.
 
Hello,
thank you at first for your information,
the method 'GetLastWin32Error' is not a possible way to get the last error in Progress, but:
we have researched that the dll has to be compiled in another way (=> to Visual Basic and not to C).
No we get the last error by using simply a Variable in the following way:
def var ret as int no-undo.
assign ret = <handle:method(Parameters)>.
That's all.

Matthias

Lee Curzon said:
Yes, I think you are right.

You want an equivalent of Err.LastDLLError. I don't know of any Win32 api equivalent.

There is an equivalent .Net call (GetLastWin32Error), but I wouldn't know how to make use of this from the 4GL. Perhaps someone here with .Net experience can advise.

Apologies for the Red Herring.
 
Thanks Matthias,

Do you know if this is something that can be used generally for COM objects?

ie. compile to VB gives useful error code.

I would be suprised if it is a general solution.

Lee
 
Hello Lee,

sorry I don't know it, but I can tell you that our com-object is a dll with some functions and first the programmers comiled it for C(++). Now compiled for VB I got the error messages.

Matthias



Lee Curzon said:
Thanks Matthias,

Do you know if this is something that can be used generally for COM objects?

ie. compile to VB gives useful error code.

I would be suprised if it is a general solution.

Lee
 
Top