Click here to Skip to main content
15,867,771 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, I need to use the Microsoft's GetLogicalDriveStrings() function to retrieve the drives list.
Is there any function to replace that function, in order to make my code cross-platform?

Thank you very much
Posted
Comments
LloydA111 11-Jul-10 10:02am    
Cross platform? Well that API will only work on Microsoft platforms, so you would need to use a different API for other platforms.

1 solution

In the most of cases there is not an equivalent of an API when moving from a platform to another; writing cross-platform code then mean to write down a series of #ifdef directives, dependant to the active platform, so that you make your work in a diferent way depending on the platform API.

To write cross-platform software is a very complex task; fortunately there are frameworks that deal with it.

Why don't you have a look to Qt - A cross-platform application and UI framework[^] or wxWidgets[^]
 
Share this answer
 
v2
Comments
SpaceSoft 12-Jul-10 14:16pm    
I'm sorry, i pressed the wrong button when replying.
So you think that there isn't a way to retrieve a list of logical drives on the pc without using microsoft's API? Including a framework in my project is an hard job for me.
Sauro Viti 12-Jul-10 16:03pm    
Let's say: if the most of your application is written using ANSI C/C++ and you need just a few number of functions that are platform dependant, you can define a function for each platform-dependant feature that you need, and in the implementation of the function use #ifdef to achieve the goal using API that are specific to each platform (#ifdef WIN32 for Windows and so on).
If your application is a GUI (windowed) one, then this is an hard job because you are using a lot of API specific to the operating system. However how many chances there are that while the application grow you don't need other stuffs that are platform specific? And again, on Linux you have mount points, not drive letters... You need to consider each aspect of your application in a cross-platform scenario before choosing a way to solve your problem.
SpaceSoft 12-Jul-10 17:06pm    
I think you're right. I didn't consider the cross-platform problem of disks' views. That a problem. I'll look to this problem later; however, thank for your answer very much.
A little note: I'm italian, we can keep in contact if you want. Thank you again
Sauro Viti 13-Jul-10 2:51am    
Allora in bocca al lupo per il tuo progetto! Di dove sei?
SpaceSoft 13-Jul-10 7:45am    
Sono di un paese sperduto tra le campagne tra la provincia di Ferrara e Ravenna...you?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900