Easy WinAPI declaration (like Visual Basic)

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

Easy WinAPI declaration (like Visual Basic)

Postby 1134i » Jan 03, 2008 6:31

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: 1704
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.
Contact:

Postby Sisophon2001 » Jan 03, 2008 9:26

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: 3801
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Postby v1ctor » Jan 03, 2008 22:40

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

Postby Sisophon2001 » Jan 04, 2008 2:33

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

Postby VirusScanner » Jan 05, 2008 4:45

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

Postby Sisophon2001 » Jan 05, 2008 8:20

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: 3801
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Postby v1ctor » Jan 05, 2008 11:04

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

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 3 guests