Skip to content

Instantly share code, notes, and snippets.

View KravitzMC's full-sized avatar
🌴

SnorTag KravitzMC

🌴
  • Hatyai Songkhla, Thailand
View GitHub Profile
@KravitzMC
KravitzMC / genericerrorGDI.md
Last active June 25, 2025 08:38
⚠️ Fix Any A generic error occurred in GDI+

🛠️ Fix "A generic error occurred in GDI+"

When you are certain that the binary data is an image. this issue results in a System.Runtime.InteropServices.ExternalException when attempting to save it otherwise.


Common Causes

  • Issues with GDI+ handles image encoders
  • You are trying to fix it but incompatibilities any with
HUbAC{NxtZ2SfV1+0x*..R`UJ*#|Fv6v8k%|d9R%mEhxEs16&&QDAzD2xRZc9ae
@KravitzMC
KravitzMC / fetch_vcdist.py
Created June 12, 2024 11:13 — forked from donno/fetch_vcdist.py
Downloads and extract the Visual C++ Redistributables.
"""Downloads and extract the Visual C++ Redistributables.
This is useful when working with minidump files as the user may be running
with a new different version of the runtime. This script aims to maintain
a copy of the various versions.
Versions are normally added once I encounter them, in November 2022, I added
a rather large back catalogue of versions.
This requires dark.exe from Wix (http://wixtoolset.org/releases/) and
@KravitzMC
KravitzMC / CombindDLLFiles.md
Last active May 28, 2025 06:58
[old version ] C# .NET Framework Winform how to combine *.dll and other to Executable Single

🛠️ Combine .NET DLL Files with Costura.Fody

This guide explains how to embed DLL files into a single executable using Costura.Fody.


📦 1. Install Costura.Fody

Install the Costura.Fody NuGet package into your current project:

private string GetVSP3ApplicationPath()
{
string defaultAppName = "HW Virtual Serial Port";
string defautAppExec = "HW_VSP3_client.exe";
string path_result = string.Empty;
string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))
{
foreach (string skName in rk.GetSubKeyNames())
{
@KravitzMC
KravitzMC / MemoryStreamExtensions.cs
Last active May 2, 2024 09:30
MemoryStreamExtensions
// This is Extension about append stream byte array in realtime similar StringBuilder
public static class MemoryStreamExtensions
{
public static void Append(this MemoryStream stream, byte value)
{
stream.Append(new[] { value });
}
public static void Append(this MemoryStream stream, byte[] values)
@KravitzMC
KravitzMC / CustomCursor.cs
Last active January 26, 2024 08:07
C# Custom cursor
[DllImport("user32.dll")]
private static extern IntPtr LoadCursorFromFile(string lpFileName);
/// <summary>
/// Load .cur File
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
internal Cursor GetCursor(string fileName)
{
@KravitzMC
KravitzMC / Idlestate.cs
Created December 14, 2023 10:14
C# how to disable Application Idle
public class AppStateManager
{
private const uint ES_CONTINUOUS = 0x80000000;
private const uint ES_SYSTEM_REQUIRED = 0x00000001;
private uint execstate;
[DllImport("kernel32.dll")]
public static extern uint SetThreadExecutionState(uint esFlags);
public void DisableIdle()
@KravitzMC
KravitzMC / MultiColumnComboBoxExt.cs
Last active December 26, 2023 08:37
MultiColumnComboBox Extension (Syncfusion)
namespace SASE.RegisterTransaction.Controls
{
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Windows.Forms;
public class MultiColumnComboBoxExt : Syncfusion.Windows.Forms.Tools.MultiColumnComboBox
{
private Type _SourceProperty;
@KravitzMC
KravitzMC / fxdialog.cs
Created November 5, 2023 05:36
C# แก้ปัญหากรณี Show Form Dialog แล้วเกิดหายไป
//หลักในการแสดง Form Dialog Mode แบบไม่ให้สูญหายซ่อนตัวไปในระหว่างเรียกใช้งานสามารถทำได้โดย
frmViewTransaction fx = new frmViewTransaction();
//โดยที่ไปจะมีการเรียกใช้ Form ประมาณนี้ ซึ่งบางครั้งเกิดมี Formหายไปในระหว่างเรียกใช้
view_register.ShowDialog();
//Solution ---> ให่ใส่พารามิเตอร์ this เข้าไปเพื่อแก้ปัญหาจุดนี้
view_register.ShowDialog(this);