Hello, I have this C++ code, I dunno how it works..

Anyway, I'd like to have it translated to Delphi.

If anyone can help me out, I'd be glad.

typedef void (*t_ChatPrint)		( char * );
t_ChatPrint	ChatPrint		= (t_ChatPrint)0x0054E410;
void ChatPrintf( const char *format, ... )
	va_list	ap;
	char	szBuffer[512] = "";

	va_start( ap, format );
	_vsnprintf_s( szBuffer, 512, 511, format, ap );
	va_end( ap );

	ChatPrint( szBuffer );

We use it like this:

ChatPrintf("Hello my %s.","friend");

Thanks in advance.

7 Years
Discussion Span
Last Post by lelejau

Why would you want to translate something that's hard wired to a specific address?

typedef void (*t_ChatPrint) ( char * );
t_ChatPrint ChatPrint = (t_ChatPrint)0x0054E410;

Your function pointer ChatPrint is hard wired to 0x0054E410..

Can I ask you a question? Why are you translating code when you don't even know its function.


I do know what it does, just dont know how it works.

This functions prints a message inside the chat of a game.

Edited by lelejau: n/a


Well quickly, the function 'ChatPrintf' is collecting its arguments in a 'buffer' szBuffer according to the format string 'const char *format' and then handing the buffer off to your function pointer 'ChatPrint'.

If you hope to understand this please read this link..


Edited by gerard4143: n/a


I understand it, but I want to translate this code to Delphi. I know more delphi than C++, I could do more things with this code in delphi.



I dont know how to translate it to delphi. Any1 can help me?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.