Skip to content

Instantly share code, notes, and snippets.

View johnhmj's full-sized avatar
😃
online

John "DumbSheep" Hsieh johnhmj

😃
online
View GitHub Profile
#include "SingleInstance.h"
//
CSingleInstance::CSingleInstance(TCHAR* pMutexName)
{
this->m_hMutex = CreateMutex(NULL, FALSE, pMutexName);
this->m_bExist = (ERROR_ALREADY_EXISTS == GetLastError())?TRUE:FALSE;
}
CSingleInstance::CSingleInstance(const CSingleInstance& instance)
{
if (this == &instance)
#include "WindowPosition.h"
//
CWndPos::CWndPos()
{
InitStruct(&this->m_pos, SWndPos);
InitStruct(&this->m_wndSize, SWndSize);
this->m_sysSize.width = GetSystemMetrics(SM_CXSCREEN);
this->m_sysSize.height = GetSystemMetrics(SM_CYSCREEN);
}
CWndPos::CWndPos(HWND hWnd)
@johnhmj
johnhmj / InitStruct.h
Last active April 3, 2017 22:32
Win32 C/C++ InitStruct macro, initialize your structure as ZeroMemory, http://johnmhsheep.pixnet.net/blog, https://johnmhsieh.blogspot.com/
#ifndef _INITSTRUCT_H_
#define _INITSTRUCT_H_
//
// initialize struct
#define InitStruct(s, t) memset((void*) s, 0x0, sizeof(t))
//
// copy struct
#define CopyStruct(s_dst, s_src, t) memcpy((void*) s_dst, (void*) s_src, sizeof(t))
//
#endif
#include "WinMainCmdline.h"
//
CCmdLine::CCmdLine()
{
this->m_lpCmdLine = NULL;
}
CCmdLine::CCmdLine(const CCmdLine& cl)
{
unsigned int nBufferSize = 0;
this->m_lpCmdLine = NULL;
@johnhmj
johnhmj / SingleInstance.cpp
Last active April 3, 2017 22:33
Win32 C/C++ Only one instance of an application is allowed to run, http://johnmhsheep.pixnet.net/blog, https://johnmhsieh.blogspot.com/
#include "SingleInstance.h"
//
CSingleInstance::CSingleInstance(TCHAR* pMutexName)
{
this->m_hMutex = CreateMutex(NULL, FALSE, pMutexName);
this->m_bExist = (ERROR_ALREADY_EXISTS == GetLastError())?TRUE:FALSE;
}
CSingleInstance::CSingleInstance(const CSingleInstance& instance)
{
if (this == &instance)
@johnhmj
johnhmj / sitemap.xml
Last active July 13, 2016 03:37
sitemap.xml from XML-Sitemaps.com
<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->
@johnhmj
johnhmj / main.cpp
Last active August 29, 2015 14:22
Quiz 3 & 4(IP = 120.117.156.61, STUST), https://www.ptt.cc/bbs/C_and_CPP/M.1433693969.A.3FD.html
#include <iostream>
#include <limits>
#define STUDENTNUMBER 8
#define STUDENTDATA 4
void ScoreInput(int a[][STUDENTDATA]);
void ScorePrint(int a[][STUDENTDATA]);
void ScoreSorting(int a[][STUDENTDATA], int f);
using std::cin;
using std::cout;
using std::endl;
@johnhmj
johnhmj / AAEngine_Compare.txt
Last active August 29, 2015 14:07
User's settings of AAEngine.ini (CL139553)
正在比較檔案 AAEngine_Default.ini 和 AAENGINE_UPDATED.INI
***** AAEngine_Default.ini
BuildingQuadStaticMeshName=EngineBuildings.BuildingQuadMesh
ProcBuildingLODColorTexelsPerWorldUnit=0.075
ProcBuildingLODLightingTexelsPerWorldUnit=0.015
MaxProcBuildingLODColorTextureSize=1024
***** AAENGINE_UPDATED.INI
BuildingQuadStaticMeshName=EngineBuildings.BuildingQuadMesh
ProcBuildingLODColorTexelsPerWorldUnit=0.075000
ProcBuildingLODLightingTexelsPerWorldUnit=0.015000
@johnhmj
johnhmj / main.cpp
Created May 19, 2014 00:39
server of Winsock localhost connection in May 19, 2014
#include "w32socket.h"
#include <iostream>
#include <Windows.h>
//
int main(int argc, char* argv[])
{
char domain[] = "localhost";
char ip[] = "127.0.0.1";
char request[] = "from server\n";
char buffer[BUF_SIZE];
@johnhmj
johnhmj / main.cpp
Created May 19, 2014 00:36
client of Winsock localhost connection in May 19, 2014
#include "w32socket.h"
#include <iostream>
#include <Windows.h>
//
int main(int argc, char* argv[])
{
char domain[] = "localhost";
char ip[] = "127.0.0.1";
char request[] = "from client\n";
char buffer[BUF_SIZE];