WinFBE 1.7.0 - Compiler Warning

Started by SeaVipe, August 01, 2018, 05:01:20 PM

Previous topic - Next topic

SeaVipe

This code in FireFly works properly and returns the name of the computer:

Dim lpBuffer    as ZString * ( MAX_COMPUTERNAME_LENGTH + 1 )
Dim nSize       as DWORD = SizeOf( lpBuffer )
   
If GetComputerName( @lpBuffer, @nSize ) <> 0 Then

In WinFBE - using the same compiler switches as FireFly - I get the following warning:
Quotewarning 3(1): Passing different pointer types, at parameter 1 of GETCOMPUTERNAME()
I must have a compiler switch set incorrectly.
Clive Richey

Paul Squires

WinFBE has unicode enabled. You need to use a WSTRING or Jose's CWSTR
Paul Squires
PlanetSquires Software

Paul Squires

This is easier. Once you start using CWSTR, you'll use it for everything and it makes unicode applications incredibly easy to code.

DIM AS CWSTR wszComputerName = AfxGetComputerName()
Paul Squires
PlanetSquires Software

SeaVipe

Thanks Paul. Much better - lots to learn!
Clive Richey

José Roca

#4
Anyway, if you want to use ansi for some reason, call explicitily the "A" vesion of the API procedure, i.e. GetComputerNameA instead of GetComputerName. You're getting an error because, as unicode is enabled, using GetComputerName you're calling GetComputerNameW.

I would like to remind one more time that using the ansi versions of the Windows API is innefficiwent because the ansi versions are just wrappers that convert string parameters to unicode and call the unicode versions.