Easy WinAPI declaration (like Visual Basic)

New to FreeBASIC? Post your questions here.
Post Reply
1134i
Posts: 62
Joined: Jun 05, 2005 4:39
Location: Vladivostok, Russia
Contact:

Easy WinAPI declaration (like Visual Basic)

Post by 1134i »

In Visual Basic, i can do that:

Dim A as string
Declare Function MyFavoriteWinApi (x as long, y as string)

A = "hello winapi"
call MyFavoriteWinApi (1, A)



in wb, i need to try

Call .... @A
Call .... *A
Call .... strptr(a)

and

dim x as ptr
*x = A
x = *A
x = **A
**x = A

and wait when that works


now i try to use

dim myfn as string
SystemParametersInfo SPI_SETDESKWALLPAPER, 0, ???? , SPIF_UPDATEINIFILE


maybe somewhere has wrapper (don't know how to say it in english) VB <-> FB, when i can write

vbSystemParametersInfo SPI_SETDESKWALLPAPER, 0, i , SPIF_UPDATEINIFILE

and

what is PVOID? how to use SystemParametersInfo with filename?
Sisophon2001
Posts: 1706
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.
Contact:

Post by Sisophon2001 »

Does an example help? Interesting function, I did not know how to do this until you showed me.

Garvan

Code: Select all

#include "windows.bi"

SystemParametersInfo( SPI_SETDESKWALLPAPER, 0,  _ 
  strptr("C:\WINDOWS\FluxMetal_1400x1050.bmp"), _ 
  SPIF_SENDCHANGE )
v1ctor
Site Admin
Posts: 3804
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Post by v1ctor »

Btw, STRPTR() is never needed in FB when passing any kind of string as parameter. The compiler should take care of that.
Sisophon2001
Posts: 1706
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.
Contact:

Post by Sisophon2001 »

v1ctor wrote:Btw, STRPTR() is never needed in FB when passing any kind of string as parameter. The compiler should take care of that.
This is a PVOID parameter, not a string parameter, so I think STRPTR() is needed in this case.

Garvan
VirusScanner
Posts: 775
Joined: Jul 01, 2005 18:45

Post by VirusScanner »

Literal strings are ZSTRING type, not STRING, so passing them to any pointer parameter doesn't need STRPTR.
Sisophon2001
Posts: 1706
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.
Contact:

Post by Sisophon2001 »

VirusScanner wrote:Literal strings are ZSTRING type, not STRING, so passing them to any pointer parameter doesn't need STRPTR.
VirusScanner, please try it yourself and you will see that STRPTR is required, or show me an example of what you are suggesting, I may be misunderstanding something.

Garvan
v1ctor
Site Admin
Posts: 3804
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Post by v1ctor »

Uh, sorry, i missed the PVOID part, forget what i said, Sisophon2001 is correct.
Post Reply