Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #7402 > unrolled thread

TAPI and FormatMessage

Started byKai Michael Poppe <kmpams@gmail.com>
First post2014-11-07 06:22 -0800
Last post2014-11-07 21:24 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  TAPI and FormatMessage Kai Michael Poppe <kmpams@gmail.com> - 2014-11-07 06:22 -0800
    Re: TAPI and FormatMessage "Uwe Heyer" <uwe.heyer@aristik.de> - 2014-11-07 21:24 +0000

#7402 — TAPI and FormatMessage

FromKai Michael Poppe <kmpams@gmail.com>
Date2014-11-07 06:22 -0800
SubjectTAPI and FormatMessage
Message-ID<ae55f9d9-d567-497b-a594-a7860b11819b@googlegroups.com>
Hello Group!

I am getting some response code when i try to make the TAPI driver do a lineTranslate.

This response is either 0 (which is good), or any error >= 0x80000000.

So far, I found out that using the KERNEL32-function "FormatMessage" i should get a readable string as an answer.

First, as defined in tapi.h one Needs to Change the numeric code:

#define TAPIERROR_FORMATMESSAGE(__ErrCode__)
	( (__ErrCode__) > 0xFFFF0000 ) ?
	( (__ErrCode__) & 0x0000FFFF ) :
	( ( (__ErrCode__) & 0x10000000 ) ?
	( (__ErrCode__) - 0x90000000 + 0xF000 ) :
	( (__ErrCode__) - 0x80000000 + 0xE000 ) ) )


Which i reduced to this function (I know, those > 0xFFFF0000 Errors aren't handled, but i never got one of those, so I don't care for now):

FUNCTION TapiErrorFormatMessage(nResult AS LONG) AS DWORD

	IF _AND(nResult, 0x10000000) > 0
		nResult := _AND(nResult, 0x0FFFFFFF)
		nResult := nResult + 0xF000
	ELSE
		nResult := _AND(nResult, 0x0FFFFFFF)
		nResult := nResult + 0xE000
	ENDIF

RETURN DWORD(nResult)

This Translation of numbers is working as expected (another cite from tapi.h):
 LINEERR : Start at 0x80000000
   Map to : strip off 0x80000000 and add 0xE000
   Example: 0x80000004 becomes 0x0000E004
 PHONEERR: Start at 0x90000000
   Map to : strip off 0x90000000 and add 0xF000
   Example: 0x9000000A becomes 0x0000F00A

With another Look around Google I found an example to make KERNEL32.FormatMessage tell those TAPI-Errors (http://books.google.de/books?id=3M_mIvtdGqUC&pg=PA108&lpg=PA108&dq=tapi+error+codes+message&source=bl&ots=5ViwvbIWDo&sig=F7LkoJZmTImgnimAvr5Q_IDFuVU&hl=de&sa=X&ei=G9RcVLSCEcf3O-ycgYAF&ved=0CDsQ6AEwAw) - which I put into this function:

FUNCTION TapiErrorMessage(dwError AS DWORD) AS STRING PASCAL

	LOCAL pMsgBuffer  AS PSZ
	LOCAL cMessage    AS STRING

	FormatMessage(_OR(FORMAT_MESSAGE_FROM_HMODULE, FORMAT_MESSAGE_ALLOCATE_BUFFER, FORMAT_MESSAGE_IGNORE_INSERTS),;
	              GetModuleHandle(String2Psz("TAPI32.DLL")),;
	              dwError,;
	              0,;
	              @pMsgBuffer,;
	              1024,;
	              NULL)

	cMessage := Psz2String(pMsgBuffer)

	LocalFree(pMsgBuffer)

	IF Right(cMessage, 2) = CRLF
		cMessage := Left(cMessage, SLen(cMessage) - 2)
	ENDIF

RETURN cMessage

Yet, no matter what dwError I put into the aforementioned function from TapiErrorFormatMessage, i only get back empty strings. I tried using GetModuleHandle for TAPI, TAPI3 and TAPIUI as DLLs also, but it returns 0x0 so there's obviously no difference. Only TAPI32.DLL has a ModuleHandle > 0.

I would be grateful for any hints as to make this work in VO.

Regards

Kai

[toc] | [next] | [standalone]


#7403

From"Uwe Heyer" <uwe.heyer@aristik.de>
Date2014-11-07 21:24 +0000
Message-ID<cc4rl6F8iq5U1@mid.individual.net>
In reply to#7402
Kai Michael Poppe wrote:

>
> 
> FUNCTION TapiErrorMessage(dwError AS DWORD) AS STRING PASCAL
> 
> 	LOCAL pMsgBuffer  AS PSZ
> 	LOCAL cMessage    AS STRING
> 
> 	FormatMessage(_OR(FORMAT_MESSAGE_FROM_HMODULE,
> FORMAT_MESSAGE_ALLOCATE_BUFFER, FORMAT_MESSAGE_IGNORE_INSERTS),;
> GetModuleHandle(String2Psz("TAPI32.DLL")),; 	              dwError,;
> 	              0,;
> 	              @pMsgBuffer,;
> 	              1024,;
> 	              NULL)
> 
> 	cMessage := Psz2String(pMsgBuffer)
> 
> 	LocalFree(pMsgBuffer)
> 
> 	IF Right(cMessage, 2) = CRLF
> 		cMessage := Left(cMessage, SLen(cMessage) - 2)
> 	ENDIF
> 
> RETURN cMessage
> 
> Yet, no matter what dwError I put into the aforementioned function
> from TapiErrorFormatMessage, i only get back empty strings. I tried
> using GetModuleHandle for TAPI, TAPI3 and TAPIUI as DLLs also, but it
> returns 0x0 so there's obviously no difference. Only TAPI32.DLL has a
> ModuleHandle > 0.
> 
> I would be grateful for any hints as to make this work in VO.
> 
> Regards
> 
> Kai



-- 

Hi Kai,


first of all I would inspect the return code from FormatMessage


if FormatMessage(...) = 0  // Error
	? GetLastError()	// Get error number
      inspect error for description string 
	using another FormatMessage call
	or let us know this error number

else		// ok
     > 0 == char/byte counter of pMsgBuffer 

second, I would use 0 for sizeof(buffer) (your 1024)



Ahoj
-Uwe






   

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web