wsprintf is missing

Windows specific forum
Robin
New User
New User
Posts: 2
Joined: Fri Sep 19, 2003 9:35 am

wsprintf is missing

Post by Robin »

i'm not quite sure but i think this should also be written in the bug list: the windows-api-call wsprintf is not supported by purebasic!
wvsprintfa can be used but i have not managed to get a working example for this... can anyone supply one?
Poplar
User
User
Posts: 16
Joined: Sun Apr 30, 2017 12:27 pm

Re: wsprintf is missing

Post by Poplar »

OpenLibrary(0, "User32.dll")
PrototypeC.i protoFunction(*buf.p-unicode, a.p-unicode, b.l)
wsprintf.protoFunction = GetFunction(0, "wsprintfW")
CloseLibrary(0)

a = 5
n.s = "A: %d"

buffer.s = Space(50)

CharsWritten = wsprintf(@buffer, n, a)

Debug buffer
Debug CharsWritten
Debug Len(buffer)
Poplar
User
User
Posts: 16
Joined: Sun Apr 30, 2017 12:27 pm

Re: wsprintf is missing

Post by Poplar »

Code: Select all

OpenConsole()
u32dll = OpenLibrary(#PB_Any, "user32.dll")
*f = GetFunction(u32dll, "wsprintfW")
CloseLibrary(u32dll)

szBuffer.s = Space(1024)
szFormat.s = "%-13s %3d %-15s%c%6u %4d %3s %3s %4s %4s"
szTemp1.s = "第一个字符串。"
szTemp2.s = "第二个字符串。"
szTemp3.s = "第三个字符串。"
szTemp4.s = "第四个字符串。"
szTemp5.s = "第五个字符串。"
szTemp6.s = "第六个字符串。"

If *f
  CallCFunctionFast(*f, @szBuffer, @szFormat, @szTemp1, 42, @szTemp2, 65,1234, 5678, @szTemp3, @szTemp4, @szTemp5, @szTemp6)
  Print(szBuffer)  
EndIf

Input()
CloseConsole()
Post Reply