I have been building a sample WPF Application. I have used some undocumented codes like SetWindowCompositionAttribute()
method. Once I run my application it works fine without any problem but when i exit my application using alt+F4 I got a message in the output window.
The program '[10172] Sample.exe' has exited with code -1 (0xffffffff).
I think there is some kind of error occurred. I know that the exit code 0
represents the program executed without any errors.
Does this -1
represents any kind of memory leak? How can i debug and check what error is it causing.
For reference, Here is my code which causes the issue:
public static void SetHBrush(IntPtr hwnd, uint brush) {
var accent = new AccentPolicy {
AccentState = AccentState.ACCENT_ENABLE_GRADIENT,
GradientColor = brush // 0xFFFFFF
};
var accentStructSize = Marshal.SizeOf(accent);
var accentPtr = Marshal.AllocHGlobal(accentStructSize);
Marshal.StructureToPtr(accent, accentPtr, false);
var data = new WindowCompositionAttributeData {
Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
SizeOfData = accentStructSize,
Data = accentPtr
};
NativeMethods.SetWindowCompositionAttribute(hwnd, ref data);
Marshal.FreeHGlobal(accentPtr);
}
Here is the link where i have fetched the code : sample-win32-acrylicblur
User contributions licensed under CC BY-SA 3.0