Skip to content

Instantly share code, notes, and snippets.

@pachuco
pachuco / displayswitch.c
Last active June 29, 2022 02:34
Utility to switch displays in winXP
#include <windows.h>
#include <stdio.h>
#include <stdint.h>
#define DEVNAME_LEN 32
#define A2I(x) ((uint8_t)(x-48))
static DEVMODEA dmActive;
static DEVMODEA dmWanted;
static char nameActive[DEVNAME_LEN];
@pachuco
pachuco / dynload.h
Last active November 20, 2020 13:59
Easilly create function pointers out of existing function definitions
#pragma once
#include <windows.h>
#define DEFFUN_OBJ(_HMOD, _ERR, _FNAME) __typeof__(_FNAME) *pf##_FNAME = NULL
#define DEFFUN_EXT(_HMOD, _ERR, _FNAME) extern __typeof__(_FNAME) *pf##_FNAME
#define DYNLOAD(_HMOD, _ERR, _FNAME) _ERR = _ERR ? _ERR : !(pf##_FNAME = (void*)GetProcAddress(_HMOD, #_FNAME))
//usage scenario
//You have a header full of function definitions that would result in linking to dll
//But you want to use them as dynamically loaded functions instead.
@pachuco
pachuco / pastamasta.c
Created September 2, 2021 17:39
Util to turn text clipboard into keystroke sequence
#include <stdio.h>
#include <windows.h>
//Use: copy text to clipboard and press HOTKEY to type it back
// for those places where system clipboard doesn't reach.
#define HOTKEY VK_SCROLL
#define BLEEP_PITCH 2000
//#define KDELAY 5
@pachuco
pachuco / main_stupidfm.c
Last active July 2, 2024 18:07
Stupid FM synth
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <math.h>
#include <windows.h>
#include <conio.h>