SetupAPI, Cfg+ headers (for PureBasic Community)

Windows specific forum
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

SetupAPI, Cfg+ headers (for PureBasic Community)

Post by Thunder93 »

Last edited by Thunder93 on Sun Mar 27, 2016 9:27 pm, edited 1 time in total.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
skywalk
Addict
Addict
Posts: 3997
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: SetupAPI header ported to PureBasic.

Post by skywalk »

Small note:
You can save some lines by moving your Global Prototype defines inside Procedure setupapi_Init().

FROM:
Global SetupAddInstallSectionToDiskSpaceList.SetupAddInstallSectionToDiskSpaceList
;+ the following line in Procedure setupapi_Init()
SetupAddInstallSectionToDiskSpaceList = GetFunction(setupapi, "SetupAddInstallSectionToDiskSpaceList"+sExt)

TO:
Global SetupAddInstallSectionToDiskSpaceList.SetupAddInstallSectionToDiskSpaceList = GetFunction(setupapi, "SetupAddInstallSectionToDiskSpaceList"+sExt)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: SetupAPI header ported to PureBasic.

Post by Thunder93 »

very good suggestion skywalk, thank you.


.. Updated it.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: SetupAPI header ported to PureBasic.

Post by nco2k »

bool is 4 byte, boolean is 1 byte. you are using .b for both.

you should replace [#ANYSIZE_ARRAY] with [0]. if you want to access an index > 0 (and you usually will), the debugger will fire an "array index out of bounds" error. if you use [0], you can browse any index you want. the only drawback is that SizeOf() will report the wrong size, since 0 is nothing. so keep that in mind.

why are you using data types as names?

Code: Select all

SetupAddInstallSectionToDiskSpaceList(HDSKSPC,HINF1,HINF2,PCSTR,PVOID,UINT.l)
the original names make much more sense and increase the readability a lot.

Code: Select all

SetupAddInstallSectionToDiskSpaceList(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2.l)
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
Bisonte
Addict
Addict
Posts: 1232
Joined: Tue Oct 09, 2007 2:15 am

Re: SetupAPI header ported to PureBasic.

Post by Bisonte »

The "70% mistake" : Check the datatypes....

A long is not the variable for a handle. So this code is x86 only !

(See setupapi.l)
PureBasic 6.10 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: SetupAPI header ported to PureBasic.

Post by Thunder93 »

Thanks nco2k.

On a whim in the middle of the night, I've decided to convert setupapi C header. Few hours in, no coffee, and manually doing this all, my senses obviously been dulled. I couldn't exactly sleep when I tried, and I didn't have nothing better to-do, so I came to the computer and played around.

True, increased readability, to have names instead of data-types. I was planning on, at some point making this change anyways. However since much time spent onto this already, and I wasn't in the right frame of mind. I figured mistakes can be easier spotted, and replaced easily for the time being. When I do make this change, I'll probably have to spend another few hours just to lookup all the names and make the changes.


Updated the file.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: SetupAPI header ported to PureBasic.

Post by Thunder93 »

I think Its mostly the Prototype types that I messed up on, halfway into doing this. Corrected these, now it should be fully x64 compatible.
Last edited by Thunder93 on Fri Mar 18, 2016 4:11 pm, edited 1 time in total.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: SetupAPI header ported to PureBasic.

Post by nco2k »

no worries, everyone makes mistakes. when i have to convert a lot winapi stuff, i copy everything into notepad++ and record some makros. great time saver. :)

btw what Bisonte was trying to say is that you should change:

Code: Select all

Shared setupapi.l
to:

Code: Select all

Shared setupapi.i
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: SetupAPI header ported to PureBasic.

Post by Thunder93 »

Thanks nco2k. I've overlooked that part in Bisonte's post. @Bisonte: Good catch.

I have Notepad++ installed, however I've never explored its massive list of features. I'll have to look into this Macro recording.

file updated again. :P
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: SetupAPI header ported to PureBasic.

Post by Thunder93 »

I've updated it.

Now using true names instead of data-types for parameter names..... @nco2k, better? :wink:

Added more prototypes. Now covers all Setup* functions from setupapi.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Post Reply