Q: How can I check the free space on a partition?
A:
Note: Most of the material in this article is taken from codeguru.com
Q: How to get the available logical partitions on my PC?
A:
Q: How to get information about a partition?
A:
Q: How to check for the existance of a directory/file?
A:
Note: Most of the material in this article is taken from codeguru.com
Q: How to retrieve the version information of my application?
A: To retrieve the version information you can use the following functions...
BOOL GetFileVersionInfo(LPTSTR lptstrFilename,
DWORD dwHandle,
DWORD dwLen,
LPVOID lpData)
BOOL VerQueryValue(const LPVOID pBlock,
LPTSTR lpSubBlock,
LPVOID *lplpBuffer,
PUINT puLen)
DWORD VerLanguageName(DWORD wLang, LPTSTR szLang, DWORD nSize)
'GetFileVersionInfoSize()' returns the size of the version information. 'GetFileVersionInfo()' uses information retrieved by 'GetFileVersionInfoSize()' to retrieve a structure that contains the version information. 'VerQueryValue()' retrieves a specific member from that structure. Your setup program needs to call those function depending on the error code returned by e.g. 'VerInstallFile()'.
The following is an example class which wraps the whole thing...
The above class can be used as follows:
Note: Most of the material in this article is taken from codeguru.com
Q: How to get the application directory?
A:
Q: How to get the system directory?
A:
Q: How to get the windows directory?
A:
Note: Most of the material in this article is taken from codeguru.com
Q: How to set the current working directory?
A:
Q: How to get the current working directory?
A:
Q: How to get Application Data path in user profile directory?
A:
Q: How to get User Profile path (if available in environment)?
A:
Note: Most of the material in this article is taken from codeguru.com
Q: How to get the application name?
A: If this is a MFC application you could do
In all other cases the function 'GetModuleFileName()' can be used...
Note: Most of the material in this article is taken from codeguru.com
Q: How to get the reason for a failure of a SDK function?
A: First of all, take a look in MSDN and read the documentation of the function. See the meaning of the returned value.
Most Windows SDK functions return a value showing if the function succeeded or failed (in our example 0 if failed and nonzero if succeeded).
Usually, next is written in MSDN: To get extended error information, call 'GetLastError()'.
Also, we can get the error text using 'FormatMessage()':
The following example shows how to use it:
Note: Most of the material in this article is taken from codeguru.com