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


Groups > comp.lang.clipper.visual-objects > #7403

Re: TAPI and FormatMessage

From "Uwe Heyer" <uwe.heyer@aristik.de>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: TAPI and FormatMessage
Date 2014-11-07 21:24 +0000
Message-ID <cc4rl6F8iq5U1@mid.individual.net> (permalink)
References <ae55f9d9-d567-497b-a594-a7860b11819b@googlegroups.com>

Show all headers | View raw


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






   

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

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

csiph-web