I am developing program on window's using msys and mingw. I want to have similar function as provided by WINAPI CreateFile(). Is there any solution for this?
Regards,
Dhaval
The POSIX api for opening files is fopen - or documented # OpenGroup.
Related
How openworks behind the scenes? It calls the WinAPI such as OpenFile, CreateFile, or ReadFile?
Thanks in advance.
Ultimately the VB runtime calls CreateFile to open a file.
Definitely it doesn't use de API. The open statement uses the __vbaFileOpen() function from msvbvm60.dll.
How can I read the icons from a DLL or an EXE file, using C++ (and Qt) ?
I can't find anything relevant on google, I only get how to change application icon using qt, which is not what I need.
If I understand what you're trying to do, this should be possible through the general LoadResource function or the specific LoadIcon function. An example of the former can be found here.
You would create a handle to the exe or DLL using LoadLibrary, which you subsequently use as an argument in the LoadResource or LoadIcon function.
I don't know of any Qt functions providing similar options, but perhaps others do.
I have written and application and it loads a dll using AfxLoadLibrary and i want to unload this library memory when there is no use of it.
Is there any windows API to unload a library?
This one should do it.
BOOL AFXAPI AfxFreeLibrary(HINSTANCE hInstLib);
These functions are part of the MFC library. The pure Windows API equivalents would be LoadLibrary and FreeLibrary.
Yes, use AfxFreeLibrary
Can anybody tell if I can use the Windows APIs in my qt application?
If yes can anybody tell me the procedure to do it? I need to use the msdn winapi "GetSystemPowerStatus" in my qt application to show the battery status in my qt GUI based application.
Yes, you can use those APIs (generally speaking), by including the appropriate header files.
It will make your code platform-specific (non-portable), so if there is a cross-platform way of doing so, I would use that.
Would anyone know what the Win32 equivalent of opendir is (or if it even exists) ?
Obviously I could use FindFirstFile(Ex) with FindNextFile, but appending * to the path seems like such a hackish way to do it.
FindFirstFile and FindNextFile are the appropriate Win32 APIs. Assuming you're writing C++ code, as a portable alternative you could consider using directory_iterator from the Boost Filesystem library (which is implemented on Windows using FindFirstFile and FindNextFile).
I believe you can use CreateFile with FILE_FLAG_BACKUP_SEMANTICS and then BackupRead to read directory data, but I'm not sure what format the data is actually in. Also, you would need to be running as a user with the SE_BACKUP_NAME privilege enabled, so this is not really suitable in a general purpose application.