Skip to content

Instantly share code, notes, and snippets.

View davidglezz's full-sized avatar
😃
Happy

David Gonzalez davidglezz

😃
Happy
View GitHub Profile
@davidglezz
davidglezz / MCI_audioPLayerClass.cpp
Created November 5, 2013 10:54
Simple mp3 player class using MCI
#include <windows.h>
#include <iostream>
#include <string>
enum mode {unknown, open, playing, paused, stopped };
class MCI
{
// davidxl.blogspot.com
private:
@davidglezz
davidglezz / LaunchScreensaver.c
Created November 5, 2013 10:52
Launch Screensaver
#include <windows.h>
int main()
{
SendMessage(GetForegroundWindow(), WM_SYSCOMMAND, SC_SCREENSAVE, 0);
}
@davidglezz
davidglezz / GetKeyState_Example1.cpp
Created November 4, 2013 23:19
GetKeyState Example
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
bool shift = !!(GetKeyState(VK_SHIFT) & 0x8000);
cout << hex;
while (!( GetKeyState(VK_F7) & 0x8000 ))
@davidglezz
davidglezz / Sync-Async_CreateProcess.c
Created November 4, 2013 23:14
Asynchronous & Synchronous process
#include <windows.h>
#include <stdio.h>
static HANDLE myCreateProcess(TCHAR* cmd, BOOL sync)
{
PROCESS_INFORMATION ProcInfo = {0};
STARTUPINFO StartUp = {sizeof(STARTUPINFO)};
if (CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &StartUp, &ProcInfo))
{
@davidglezz
davidglezz / simpleExceptions.cpp
Created November 4, 2013 22:16
Simple c++ ErrorHandler with exceptions example.
#include <iostream>
#include <string>
using namespace std;
int main()
{
int error = 0;
try
{
@davidglezz
davidglezz / ConsoleGotoXY.c
Last active December 27, 2015 10:19
Windows Console color & position examples
#include <windows.h>
void write(HANDLE hStdout, const char* message)
{
DWORD t;
WriteConsole(hStdout, (const void*)message, lstrlen(message), &t, NULL);
}
bool gotoxy(HANDLE hStdout, unsigned short x, unsigned short y)
{
@davidglezz
davidglezz / GetUserNameExample.c
Created November 4, 2013 20:37
GetUserName Example
#include <windows.h>
#include <stdio.h>
int main()
{
char buffer[256] = "";
DWORD size = sizeof(buffer);
if (GetUserName(buffer, &size))
{
printf("UserName: %s\n", buffer);
@davidglezz
davidglezz / files_winapi.c
Last active October 12, 2024 23:22
Some file operations with the Windows API
#include<windows.h>
#include<iostream>
using namespace std;
// Example of file explorer
int main()
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
@davidglezz
davidglezz / GetComputerName.c
Created November 4, 2013 18:53
GetComputerName Example
#include <windows.h>
#include <stdio.h>
int main()
{
char buffer[256] = "";
DWORD size = sizeof(buffer);
if (GetComputerName(buffer, &size))
{
printf("ComputerName: %s\n", buffer);
@davidglezz
davidglezz / HideWindows.c
Created November 4, 2013 18:34
Hide windows
#include <windows.h>
int main()
{
// Example: Hide all windows
while(1)
{
HWND window = GetForegroundWindow();
ShowWindow(window, false);
}