wininet.h to PB

Windows specific forum
User avatar
Bisonte
Addict
Addict
Posts: 1320
Joined: Tue Oct 09, 2007 2:15 am

wininet.h to PB

Post by Bisonte »

Hi.

Resulting in a size of delusional (<- Google Translate)
i tried to convert the wininet.h to pb as resident.

But : Some of our "API Gurus" have a look to the structures, because my skill to
translate the correct datatypes in the structures is weak...

In the zip-archiv is the source and a resident file (PB5.1x86 Final)

download wininet.h to pb
Last edited by Bisonte on Wed May 15, 2013 7:36 pm, edited 1 time in total.
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: wininet.h to PB

Post by luis »

Hi, the first thing I notice is you replaced some (but not all ?) LPTSTR occurrences with PB strings (.s)

LPTSTR are pointers so you could simply to remove the .s

BTW: when you have doubts you can look at the stupid msft type redefinitions on msdn to see how they are defined. 90% of the time they are some kind of number (word, long, int)
"Have you tried turning it off and on again ?"
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: wininet.h to PB

Post by Shield »

luis wrote:BTW: when you have doubts you can look at the stupid msft type redefinitions on msdn to see how they are defined. 90% of the time they are some kind of number (word, long, int)
I wouldn't call it stupid. It makes a lot of sense to redefine types to avoid problems
when compiling on different systems / architectures (also for 32 / 64 compatibility).
However I do agree sometimes they overdid it. :)

@Bisonte:
You should be careful with ".l" types. Most of them should be ".i" I guess.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: wininet.h to PB

Post by luis »

It's only my opinion obviously. I call it stupid because the original idea had his merits, to instantly recognize that an anonymous "long" is very particular type of long, an HANDLE for example, and *much later* for portability as you suggested. But all that is lost now under a myriad of redefinitions often of the same thing, and what it should be a simply recognizable integer or a pointer is now VERYLONGANDVERYFAR_PTR_LONG_LONG_INT_EXTRA_V2_WIDE.
Now instead of helping it requires an interpreter, as testified by all the errors people commit when translating them.
"Have you tried turning it off and on again ?"
User avatar
Bisonte
Addict
Addict
Posts: 1320
Joined: Tue Oct 09, 2007 2:15 am

Re: wininet.h to PB

Post by Bisonte »

@Shield: hm DWORD are two words, so its a LONG in PB. I checked it with other predefined structures at the structureviewer in pb-ide.
@Luis: I thought that a Blabla.s in a structure is only a pointer to a string in memory , like LPSTR ...

Thats why I said : Someone with more skill have to check it :mrgreen:
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: wininet.h to PB

Post by Shield »

Yes, but the original size definition of "word" goes back to older times. A word is the natural unit of a processor,
so on 32 Bit systems a "word" is PB's long whereas on 64bit systems a "word" is actually PB's quad (64 bit). :)

Microsoft (and most others apparently) decided to keep the old definitions.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
Bisonte
Addict
Addict
Posts: 1320
Joined: Tue Oct 09, 2007 2:15 am

Re: wininet.h to PB

Post by Bisonte »

Shield wrote:Yes, but the original size definition of "word" goes back to older times. A word is the natural unit of a processor,
so on 32 Bit systems a "word" is PB's long whereas on 64bit systems a "word" is actually PB's quad (64 bit). :)

Microsoft (and most others apparently) decided to keep the old definitions.
But if I changed .l to .i at DWORD entries, the size of structure is not the same on x86 and x64...
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: wininet.h to PB

Post by Shield »

Why is that a requirement? That's usually how it should be.
But of course it depends on the structure itself. It's really not always easy to convert types from C. :)
So I can't say for sure what's correct in this case.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: wininet.h to PB

Post by Danilo »

int/long and unsigned int/long (and DWORD) are 32bit on Win x86 and Win x64, so PureBasic's .l is correct in structures.

Even WinAPI function calls use (unsigned) int/long (or macros like DWORD) most of the time, so they use 32bit.
The difference is that function arguments are widened to 64bit anyway in 64bit mode, giving arguments as
64bit types on stack and in registers to the functions. In structures no widening happens, so size must be correct.

With PB5.10 you should/could use: "Structure name Align #PB_Structure_AlignC"

Of course structure sizes may be different with PB32 and PB64:

Code: Select all

Structure theStructure Align #PB_Structure_AlignC
    theLong.l
    *thePointer
EndStructure

Debug SizeOf(theStructure)
Debug OffsetOf(theStructure\theLong)
Debug OffsetOf(theStructure\thePointer)
Post Reply