R – Delphi – Enumerating SATA IO Port Numbers in Windows

delphiiopascalportsata

New one for you. Im getting ready to help another programmer port his program from C# to Delphi. I cant truly read C# nor has he sent me actual source at this point so from discussion i think im going to be tackling most of this from a one function at a time standpoint.

I need to be able to get the IO Port Numbers for all SATA devices (I believe i mean devices) connected to the system. I know WMI wont do it so im not sure where to start on this one. I know the C# version of this app uses a C# class that basically parses the registry. Ive always been icky about directly reading from the registry. I feel that getting the information from windows api or related is more reliable between windows versions if possible.

Best Answer

If the original is reading the registry, and you are porting the function, reading the registry looks like a perfectly valid solution to me?

By the way, Delphi has the class TRegistry from the unit registry.pas. You can use that to read and write the registry. By default you are asking for all the rights (read/write..) on vista this can be a problem, so be sure to open readonly if you are planning to read only.

Key values:

KEY_READ
KEY_WRITE 
KEY_EXECUTE
KEY_ALL_ACCESS

These are actually sets made of the basic values:

KEY_QUERY_VALUE       
KEY_SET_VALUE         
KEY_CREATE_SUB_KEY    
KEY_ENUMERATE_SUB_KEYS
KEY_NOTIFY     
KEY_CREATE_LINK
KEY_WOW64_32KEY
KEY_WOW64_64KEY
KEY_WOW64_RES