Skip to content

Instantly share code, notes, and snippets.

View thinkhy's full-sized avatar
🐕
On vacation

thinkhy thinkhy

🐕
On vacation
View GitHub Profile
@thinkhy
thinkhy / cdecl vs. stdcall
Created February 10, 2011 12:50
汇编代码由cl.exe /FAs输出
TITLE test.c
.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA ENDS
@thinkhy
thinkhy / COM_Exception_Process_C++
Created February 14, 2011 02:25
Windows COM异常处理
COM异常操作
try
{
}
catch (_com_error& ex)
{
CString strEX = ex.Description(); // 这个最重要的信息最终却没抛出去!
if (_TKLibrary::TK_CheckDebug())
::MessageBox(NULL, strEX, _T("数据库操作异常"), MB_OK );
bR = false;
@thinkhy
thinkhy / mfc_app_singleton_C++
Created February 14, 2011 06:56
mfc 应用程序的单例运行
BOOL InitInstance()
{
m_hMutex = ::CreateMutex(NULL, FALSE, APP_MUTEX_NAME);
if (NULL == m_hMutex)
{
Suicide();
return FALSE;
}
@thinkhy
thinkhy / MFC_CUSTOM_DRAW_C++
Created February 15, 2011 05:04
ListCtrl Custom Draw
#pragma once
// CCustomListBox
class CCustomListBox : public CListBox
{
DECLARE_DYNAMIC(CCustomListBox)
////////////////////////////////////////////自绘ListBox
CArray<int> m_arySeparators;
@thinkhy
thinkhy / Delete .svn directory
Created February 28, 2011 08:15
Clean directory with SVN
#!/usr/bin/perl
use File::Path;
use strict;
use warnings;
my @tree=<*>;
foreach (@tree){
&if_a_tree($_);
}
@thinkhy
thinkhy / MsgWaitForMultipleObjects
Created March 18, 2011 06:46
演示MsgWaitForMultipleObjects的用法
// 等待打包工具初始化成功,等待时间为10秒
DWORD dwWait = WAIT_FAILED;
MSG msg;
do
{
dwWait = MsgWaitForMultipleObjects(
1,
&hEvent,
TRUE,
@thinkhy
thinkhy / log.cpp
Created March 27, 2011 16:20
A Log implement in Win32 C++
#include "stdafx.h"
#include "Cx_SeaLog.h"
#include <string>
#include <sstream>
#include <vector>
using namespace std;
#define MAX_LOGFILE_SIZE 1024*1024 // LOG文件最大为1MB
@thinkhy
thinkhy / path_do_search.c
Created April 7, 2011 10:25
WINE项目的do_search实现,代码写得不错
源码鉴赏 来源path.c wine
static BOOL do_searchW(PCWSTR file, PWSTR buffer, BOOL recurse,
PENUMDIRTREE_CALLBACKW cb, PVOID user)
{
HANDLE h;
WIN32_FIND_DATAW fd;
unsigned pos;
BOOL found = FALSE;
static const WCHAR S_AllW[] = {'*','.','*','\0'};
@thinkhy
thinkhy / path_do_search.c
Created April 7, 2011 10:25
WINE项目的do_search实现,代码写得不错
源码鉴赏 来源path.c wine
static BOOL do_searchW(PCWSTR file, PWSTR buffer, BOOL recurse,
PENUMDIRTREE_CALLBACKW cb, PVOID user)
{
HANDLE h;
WIN32_FIND_DATAW fd;
unsigned pos;
BOOL found = FALSE;
static const WCHAR S_AllW[] = {'*','.','*','\0'};
@thinkhy
thinkhy / queuelock.c
Created April 21, 2011 06:16
queuelock的实现,来源于processHacker工程
/*
* Process Hacker -
* queued lock
*
* Copyright (C) 2010-2011 wj32
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by