This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
// If have compile errors: | |
// Replace TokenElevation by (TOKEN_INFORMATION_CLASS)20 | |
// Uncomment next struct | |
/* | |
typedef struct _TOKEN_ELEVATION { | |
DWORD TokenIsElevated; | |
} TOKEN_ELEVATION, *PTOKEN_ELEVATION; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
// Get Current Folder | |
void GetFolder(char *folderName) | |
{ | |
GetModuleFileName(GetModuleHandle(NULL), folderName, MAX_PATH); | |
*(strrchr(folderName, '\\')) = 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
int main() | |
{ | |
//allocate a data | |
INPUT *data = new INPUT[3]; | |
// Move to position. data | |
data->type = INPUT_MOUSE; | |
data->mi.dx = 0; // Position x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hide cursor | |
LRESULT CALLBACK dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |
{ | |
switch(msg) | |
{ | |
// put this in your dialogProc | |
case WM_SETCURSOR: | |
SetCursor(NULL); | |
return TRUE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <Shlwapi.h> | |
#include <stdio.h> | |
#pragma comment(lib, "shlwapi.lib") | |
char* assocStr[] = | |
{ | |
"ASSOCSTR_COMMAND", | |
"ASSOCSTR_EXECUTABLE", | |
"ASSOCSTR_FRIENDLYDOCNAME", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
int main() | |
{ | |
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN); | |
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN); | |
int top = GetSystemMetrics(SM_YVIRTUALSCREEN); | |
int left = GetSystemMetrics(SM_XVIRTUALSCREEN); | |
int size = width * height * 3; | |
int headerSize = sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double exp2(double n) | |
{ | |
return pow(2.0, n); | |
} | |
double log2(double n) | |
{ | |
return log(n) / log(2.0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CenterWindow(HWND hWnd) | |
{ | |
RECT rcWin; | |
GetWindowRect(hWnd, &rcWin); | |
SetWindowPos(hWnd, NULL, (GetSystemMetrics(SM_CXFULLSCREEN) - (rcWin.right - rcWin.left + 1)) / 2, | |
(GetSystemMetrics(SM_CYFULLSCREEN) - (rcWin.bottom - rcWin.top + 1)) / 2, | |
0, 0, SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HWND of text element | |
void CopyEditToClipboard(HWND hWnd) | |
{ | |
SendMessage(hWnd, EM_SETSEL, 0, 65535L); | |
SendMessage(hWnd, WM_COPY, 0 , 0); | |
SendMessage(hWnd, EM_SETSEL, 0, 0); | |
} | |
// Example | |
CopyEditToClipboard(GetDlgItem(hwndDlg, IDC_EDIT_MAIN)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Display 'Open File' dialog-box | |
BOOL OpenFileDialog(LPSTR lpFilename) | |
{ | |
OPENFILENAME of; | |
char szFilter[] = "Music Files (*.ogg)\0*.ogg\0Image Files (*.png)\0*.png\0All files (*.*)\0*.*\0\0"; | |
char szFile[MAX_PATH] = "\0"; | |
char szTitle[] = "Select a file"; | |
char szExt[] = "ogg"; | |
of.lStructSize = sizeof(of); |