i would like to know the function which returns the drive where the windows has been installed.
for example
if we run a program with following code in windows which is installed in "C:\"
temp_char = getWindowsInstalledDrive();
should return "C:\".
please point me to that function if you know. it should be a C/C++ function.
Thanks.
You can use GetSystemDirectory(): http://msdn.microsoft.com/en-us/library/ms724373%28VS.85%29.aspx and then take the first 3 letters.
Use GetWindowsDirectory, and then extract the drive from the first three characters. This function is described as "legacy" in the help, but should work on all existing Windows versions.
Related
I want to make get and set -Systemtimeadjustment to manipulate the local clock and i want to be platform independend. So how do I get the function(name) for WinCE or Linux? I searched in google but i didn´t find anything!
Thanks!
Linux uses the adjtimex function (RFC 1305, David L. Mills). For details see Linux/kernel/time/timekeeping.c.
The two OSes work very differently in how you set the clock, so there's no way to do it "platform independently". Arno answered how it's done in Linux. in CE, it's done with SetSystemTime. You'll have to wrap the two in logic that determines at run time which to call or with #ifdef` statement to compile the right one for the right platform.
I was looking at a project that someone wanted done and in order to do it I need to edit Windows' Start Up Programs. I am unsure of where to begin looking. What I really need is just a reference to some Windows API functions that will let me do this.
Thanks
Startup programs is just a directory, I don't think there are any specific functions for it. You should be able to create shortcuts inside and that should be it.
c:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\
As Nikola Smiljanić says the Startup area is just a directory with file shortcuts in it. However it is dangerous to use a hardcoded path because this changes with different versions of Windows.
You can get the path to the startup folder with the SHGetFolderPath function and CSIDL_STARTUP as a parameter.
I'm trying to move (delete) a file to a Trash Can (in Linux) using C++ (also using QT4 for GUI). Unfortunately it seems to be quite difficult to do so and as far as I can tell there isn't a unified API for it.
I would like for my application to run not only on KDE but on GNOME, Xfce and other Linux desktop environments. That's why I'm searching for a more universal approach.
The best I could find so far is:
send2trash - but that's using Python/QT4 and not C++/QT4
trash-cli - this has the drawback of being a stand alone command line program and not a library
I would be happy with any approach that requires as little desktop environment specific code as possible. Or in other words that's as much independent from KDE/GNOME/Xfce components as possible.
Any help in finding a solution (if there even is one) would be greatly appreciated.
Why not find a terminal command to move the files and then call system() to run it for you inside your C++ program?
This might (I haven't tested it) be a possible one-liner in Linux to move files to the trash via the terminal. You would just pass the command as a quoted string to system() and call it in your C++ implementation.
The answer is in
http://www.freedesktop.org/wiki/Specifications/trash-spec
For every user a “home trash” directory MUST be available. Its name and location are $XDG_DATA_HOME/Trash
you only need to write C++ code move your file into such directory.
You can move files using boost file system and you can retrieve the XDG_DATA_HOME value using cstlib getenv.
As far as I know there's no standard trash can in Linux in the first place.
hi everybody out there i need help from u in file handling
I'm using Ubuntu as my operating system
now my c++ code has a line remove("/home/manish.yadav/Desktop/ram.txt");
last time i ran this command in C code it remove my operating system
now I'm not sure to use it or not ?
can anyone tell me proper syntax of this command so that i can use it in my code ?
is there any other way to remove files in c++ by using programs? how to do this?
how delete file using c++ program ?
try it !
unlink("/home/manish.yadav/Desktop/ram.txt");
Take a look into the reference page for std::remove on how to use it to remove files.
Concerning your OS, std::remove doesn't randomly kill OSs. Last time I tried it, the function worked as expected.
"last time i ran this command in C code it remove my operating system".
No, it didn't. Something else did, and we have no crystal ball to guess what that was.
Exactly what it says on the tin.
Also is there any way to tell what is running inside the shell?*
I suppose I could do this by looking up finding process with matching parent pids* but is that portable to windows? And how would you look up current directory of a process given pid*.
*(most to least preferable) qt or kde api/other crossplatform api/*nix and windows api?
It looks like TerminalInterfaceV2 might be exactly what I need, any extra info about it would be appreciated.