Jump to content
The simFlight Network Forums

FindWindowExA UIPCMAIN and P3Dv2


Recommended Posts

Friendly greetings !

 

I have the very latest version of FSUIPC installed and registered.

I downloaded the SDK, this one : http://fsuipc.simflight.com/beta/FSUIPC_SDK.zip

I'm using FSInterrogate2std and it works, FSUIPC is detected and i can read data.

 

So far so good  :mrgreen:

 

I'm using purebasic (just for fun, because i can), i expected to have some problem, but not this problem :

 

Here is the code, even if you don't know purebasic you'll probably understand it : 

OpenConsole()

Prototype.l FindWindowExA(hWnd1.l, hWnd2.l, lpsz1.s, lpsz2.s)

If OpenLibrary(1,"user32.dll")
  Global FindWindowEx.FindWindowExA=GetFunction(1,"FindWindowExA")
  Print("user32")
EndIf


m_hWnd = FindWindowEx(0, 0, "UIPCMAIN", "")
If (m_hWnd = 0)
  Print("noooo!")
Else
  Print("yes!")
EndIf
  
Delay(5000)

Easy, huh ?

 

Well, the problem is that it produce the output "user32noooo!" ...

I tried in unicode and non-unicode, with FindWindowExA and FindWindowExW, with administrator privilege and without.

 

Ho, and i'm not using FSWide (but i tried to detect it too, same problem)

 

So, the problem seems to be on my side, or perhaps a problem with purebasic.

But, just to be sure : This is the correct way to detect FSUIPC, isn't ?

 

That may sound like a dumb question but :

the "FSUIPC SDK" is under FS2004 table and it say "FSUIPC Software Development Kit for versions 3.999/4.80" (and i have 4.9x)

So, i wanted to be sure.

 

Or : is there another SDK hidden somewhere for version > 4.8 ?

Thank you

 

Link to comment
Share on other sites

I'm using purebasic (just for fun, because i can), i expected to have some problem, but not this problem :

Here is the code, even if you don't know purebasic you'll probably understand it : 

 

Why are you linking dynamically to FindWindowEx? Why not use it directly? After all it is a standard Windows library API. It is hardly likely to be missing.

 

Does the top level window class "UIPCMAIN" exist at the time? Did you check? You can use something like Spyxx to check.

 

Is your string in ASCII (you are explicitly selecting the "A" version of the Windows API)? If you've compiled for Wide Character use) as most modern compilers default to, I think, then the name you give will not match. If you'd used the direct call instead of dynamic linking things would have sorted themselves automatically.

 

The source for the way to interface to FSUIPC is provided in the SDK. Did you look? I think it is provided in several languages. I'm only familiar with C, the others were provided by other users.

 

Pete

Link to comment
Share on other sites

Problem solved.

 

So : 

- doesn't work with unicode enabled

- an empty string and NULL isn't the same thing (really?  :???: )

 

new code : 

OpenConsole()

Prototype.l FindWindowExA(hWnd1.l, hWnd2.l, lpsz1.s, lpsz2.b)

If OpenLibrary(1,"User32.dll")
  Global FindWindowEx.FindWindowExA=GetFunction(1,"FindWindowExA")
EndIf


m_hWnd = FindWindowEx(0, 0, "UIPCMAIN", 0)

If (m_hWnd = 0)
  Print("noooo!")
Else
  Print("yes!")
EndIf
  
Delay(5000)
Link to comment
Share on other sites

Why are you linking dynamically to FindWindowEx? Why not use it directly? After all it is a standard Windows library API. It is hardly likely to be missing.

 

Does the top level window class "UIPCMAIN" exist at the time? Did you check? You can use something like Spyxx to check.

 

Is your string in ASCII (you are explicitly selecting the "A" version of the Windows API)? If you've compiled for Wide Character use) as most modern compilers default to, I think, then the name you give will not match. If you'd used the direct call instead of dynamic linking things would have sorted themselves automatically.

 

The source for the way to interface to FSUIPC is provided in the SDK. Did you look? I think it is provided in several languages. I'm only familiar with C, the others were provided by other users.

 

Pete

 

Heh, we posted at the same time :)

 

I'm using the C code as reference but i was very confused by the "old" codebase and the fact that the website say FS2004.

Well, look like the sample code is still supposed to works with P3Dv2 and i'll assume future problems should be a PEBCAK :)

 

Thank you !

Link to comment
Share on other sites

I'm using the C code as reference but i was very confused by the "old" codebase and the fact that the website say FS2004.

 

I have no website. I supply all my stuff in the Download Links subforum here.  Enrico Schiratti's so-called "Dowson" page isn't under my control. Mostly he publishes links to the same files as the subforum here. 

 

The whole point of FSUIPC was to provide on-going compatibility for its client applcations from FS98 through FS2000, FS2002, FS2004 and now FSX and P3D. I just don't have time or patience to update a few words in so many paces when the content stays correct. The changes from FS2004 to FSx are covered by the "FSUIPC Offsets Status" document. That's further updated with data in the "Changes from version xxxx" document accompanying each new release until I get around to updating the main user (not developer) documentation, at which time I also update the Offsets Status document and the Lua documents.

 

Well, look like the sample code is still supposed to works with P3Dv2 and i'll assume future problems should be a PEBCAK  :)
 
PEBCAK?  Never heard of it, sorry.
 
Pete
Link to comment
Share on other sites

- an empty string and NULL isn't the same thing (really?  :???: )

 

Yes, really!

 

In C (and Windows API) an empty string ("") is a non-null (i.e. non-zero) pointer to a zero byte (or word for WideCharacter). NULL or a null pointer is actually zero, which isn't a valid pointer (in the sense that it can't be used as such without a vilation).

 

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.