winapi

Is WriteFile atomic?

我与影子孤独终老i 提交于 2021-02-07 03:07:29
问题 I'm designing a system that will write time series data to a file. The data is blocks of 8 bytes divided into two 4 bytes parts, time and payload. According to MSDN the WriteFile function is atomic ( http://msdn.microsoft.com/en-us/library/aa365747(VS.85).aspx ), if the data written is less than a sector in size. Since the file will only contain these blocks (there is no "structure" of the file so it's not possible to reconstruct a damaged file), added one after each other, it's vital that

Is WriteFile atomic?

和自甴很熟 提交于 2021-02-07 03:06:20
问题 I'm designing a system that will write time series data to a file. The data is blocks of 8 bytes divided into two 4 bytes parts, time and payload. According to MSDN the WriteFile function is atomic ( http://msdn.microsoft.com/en-us/library/aa365747(VS.85).aspx ), if the data written is less than a sector in size. Since the file will only contain these blocks (there is no "structure" of the file so it's not possible to reconstruct a damaged file), added one after each other, it's vital that

Is WriteFile atomic?

China☆狼群 提交于 2021-02-07 03:04:02
问题 I'm designing a system that will write time series data to a file. The data is blocks of 8 bytes divided into two 4 bytes parts, time and payload. According to MSDN the WriteFile function is atomic ( http://msdn.microsoft.com/en-us/library/aa365747(VS.85).aspx ), if the data written is less than a sector in size. Since the file will only contain these blocks (there is no "structure" of the file so it's not possible to reconstruct a damaged file), added one after each other, it's vital that

How to get instance of TForm from a Handle?

时光毁灭记忆、已成空白 提交于 2021-02-07 02:59:43
问题 I'm converting some functions into a DLL which relate to Windows 7 functionality. I can't pass a TForm through DLL, so I need to pass its handle instead. except, once I have that handle on the other side, how do I reconstruct it back into a TForm instance? Also, what's the appropriate way to pass the handle (HWND) through a Delphi DLL to be compatible to call from C# for example? If not possible, then I at least need to know how to change the color of a window using windows API only, no

Save embedded resource to the file system

点点圈 提交于 2021-02-06 13:34:21
问题 I use this code to load embedded resource (bitmap image) HRSRC hResInfo = ::FindResource(hInstance, MAKEINTRESOURCE(resourceId), RT_BITMAP); HGLOBAL hRes = ::LoadResource(hInstance, hResInfo); LPVOID memRes = ::LockResource(hRes); DWORD sizeRes = ::SizeofResource(hInstance, hResInfo); It works fine. How I can to save it to the file C:\image.bmp ? This code creates only empty file: HANDLE hFile = ::CreateFile(L"C:\\image.bmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)

Save embedded resource to the file system

雨燕双飞 提交于 2021-02-06 13:28:08
问题 I use this code to load embedded resource (bitmap image) HRSRC hResInfo = ::FindResource(hInstance, MAKEINTRESOURCE(resourceId), RT_BITMAP); HGLOBAL hRes = ::LoadResource(hInstance, hResInfo); LPVOID memRes = ::LockResource(hRes); DWORD sizeRes = ::SizeofResource(hInstance, hResInfo); It works fine. How I can to save it to the file C:\image.bmp ? This code creates only empty file: HANDLE hFile = ::CreateFile(L"C:\\image.bmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)

Save embedded resource to the file system

£可爱£侵袭症+ 提交于 2021-02-06 13:27:32
问题 I use this code to load embedded resource (bitmap image) HRSRC hResInfo = ::FindResource(hInstance, MAKEINTRESOURCE(resourceId), RT_BITMAP); HGLOBAL hRes = ::LoadResource(hInstance, hResInfo); LPVOID memRes = ::LockResource(hRes); DWORD sizeRes = ::SizeofResource(hInstance, hResInfo); It works fine. How I can to save it to the file C:\image.bmp ? This code creates only empty file: HANDLE hFile = ::CreateFile(L"C:\\image.bmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)

Save embedded resource to the file system

隐身守侯 提交于 2021-02-06 13:26:07
问题 I use this code to load embedded resource (bitmap image) HRSRC hResInfo = ::FindResource(hInstance, MAKEINTRESOURCE(resourceId), RT_BITMAP); HGLOBAL hRes = ::LoadResource(hInstance, hResInfo); LPVOID memRes = ::LockResource(hRes); DWORD sizeRes = ::SizeofResource(hInstance, hResInfo); It works fine. How I can to save it to the file C:\image.bmp ? This code creates only empty file: HANDLE hFile = ::CreateFile(L"C:\\image.bmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)

Why does the console window shrink when using GetConsoleScreenBufferInfoEx in Windows?

喜你入骨 提交于 2021-02-06 12:52:14
问题 I'm trying to set the background and foreground colors of the Windows command line console by using GetConsoleScreenBufferInfoEx and SetConsoleScreenBufferInfoEx . I'm doing it in Python, by using wintypes, and sofar it works. But there's something odd happening: the window shrinks a little at every call. This is how the calling code looks like: def GetConsoleScreenBufferInfoEx(handle): csbi = CONSOLE_SCREEN_BUFFER_INFOEX() # a structure csbi.cbSize = 96 # needs to be set success =

Start/Stop services using JNA

风流意气都作罢 提交于 2021-02-06 11:09:48
问题 I am writing a utility to start and stop windows services. The program will be distributed across many computers with differing levels of user privileges so I don't want to use the command line. I've tried using JNA, import com.sun.jna.platform.win32.W32Service; import com.sun.jna.platform.win32.W32ServiceManager; import com.sun.jna.platform.win32.Winsvc; /** * * @author */ public class WindowsServices { /** * @param args the command line arguments */ public static void main(String[] args) {