何年前?
もういっちょテスト。懐かし(?)のSSE判定。
なんか、1回だけ使ったことあったな。
/* Distinguish an Expansion function. */ #include <stdio.h> #define FLAG_MMX 0x00800000 #define FLAG_3DNOW 0x80000000 #define FLAG_SSE 0x02000000 #define HAS_MMX 1 #define HAS_3DNOW 2 #define HAS_SSE 3 void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx) { unsigned int dwAX, dwBX, dwCX, dwDX; _asm { mov eax,op cpuid mov dwAX,eax mov dwBX,ebx mov dwCX,ecx mov dwDX,edx } *eax = dwAX; *ebx = dwBX; *ecx = dwCX; *edx = dwDX; } int check_cpu(void) { int c[5]; /* check CPU has CPUID */ cpuid(0, &c[1], &c[2], &c[3], &c[4]); if(c[1] < 1) return( 0 ); /* check CPU has SSE */ cpuid(1, &c[1], &c[2], &c[3], &c[4]); if((c[4] & FLAG_SSE) == FLAG_SSE) return( HAS_SSE ); /* check CPU has 3DNow! */ cpuid(0x80000001, &c[1], &c[2], &c[3], &c[4]); if((c[4] & FLAG_3DNOW) == FLAG_3DNOW) return( HAS_3DNOW ); /* check CPU has MMX */ cpuid(1, &c[1], &c[2], &c[3], &c[4]); if((c[4] & FLAG_MMX) == FLAG_MMX) return( HAS_MMX ); return( 0 ); } int main(void) { int cpu_code; cpu_code = check_cpu(); printf("MMX:\t1\n"); printf("3DNOW:\t2\n"); printf("SSE:\t3\n"); printf("This Computer has function: %d\n", cpu_code); printf("\n[Press Enter]"); getchar(); return( cpu_code ); }
cppってか完全にcだけど。(↓もだけど)
しかしこのシンタックスハイライトは、すごいっちゅーか、便利すぎるな。
Terapadとかのテキスト装飾ルールに適応したい。というか、ローカルソフトとして欲しいかも。
ページで作ってからソース開くのでも良いんだけどAPIとしても欲しいところだね。(笑)
コレだけのために使う価値ありだな。
c
/************************************************* Title: スプラッシュ・お試し Date: 2005.12.5 Ver: 0.0.0.4 *************************************************/ #include <windows.h> #include "resource.h" void ShowMyBMP(HWND hWnd, HDC hdc) { HDC hmdc; HBITMAP hBitmap; BITMAP bmp; HINSTANCE hInst; int BMP_W, BMP_H; hInst = ( HINSTANCE )GetWindowLong(hWnd, GWL_HINSTANCE); hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1)); GetObject(hBitmap, sizeof(BITMAP), &bmp); BMP_W = ( int )bmp.bmWidth; BMP_H = ( int )bmp.bmHeight; hmdc = CreateCompatibleDC(hdc); SelectObject(hmdc, hBitmap); BitBlt(hdc, 0, 0, BMP_W, BMP_H, hmdc, 0, 0, SRCCOPY); DeleteDC(hmdc); DeleteObject(hBitmap); } LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; STARTUPINFO stinfo; PROCESS_INFORMATION Procinfo; switch(uMsg) { case WM_PAINT: hdc = BeginPaint(hWnd, &ps); ShowMyBMP(hWnd, hdc); EndPaint(hWnd, &ps); stinfo.cb = sizeof(stinfo); stinfo.lpReserved = NULL; stinfo.lpDesktop = NULL; stinfo.lpTitle = NULL; stinfo.dwFlags = 0; stinfo.cbReserved2 = 0; stinfo.lpReserved2 = NULL; CreateProcess(NULL, TEXT("実行ファイル.exe"), NULL, NULL, FALSE, 0, NULL, NULL, &stinfo, &Procinfo); // ↓コレ系だとどうなん? // ShellExecute(NULL, "open", mStrItem[item_selcount], // NULL, mExePath, SW_SHOW); PostMessage(NULL, WM_PAINT, 0, 0); if(! WaitForInputIdle(Procinfo.hProcess, 1000 * 2000)) { Sleep(10); PostQuitMessage(0); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return( DefWindowProc(hWnd, uMsg, wParam, lParam) ); } return( 0 ); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int px = 0; int py = 0; int wx = 300; int wy = 180; WNDCLASS wc; //ウィンドウクラス登録 wc.style = NULL; wc.lpfnWndProc = WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); // wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = ( HBRUSH )GetStockObject(WHITE_BRUSH); // wc.hbrBackground = ( HBRUSH )(COLOR_BTNFACE+1); wc.lpszMenuName = NULL; wc.lpszClassName = TEXT("SplashWindow"); if(RegisterClass(&wc) == 0) return( 0 ); HWND hwnd = CreateWindow( TEXT("SplashWindow"), TEXT("アプリ名を書いときゃいいんじゃね?"), NULL, px, py, wx, wy, NULL, NULL, hInstance, NULL); if(hwnd == NULL) return( 0 ); RECT rc_desk; //デスクトップ全体のサイズを取得 SystemParametersInfo(SPI_GETWORKAREA, 0, &rc_desk, 0); RECT rect1; //枠も含めたサイズ GetWindowRect(hwnd, &rect1); RECT rect2; //クライアント領域(描画領域)を取得する GetClientRect(hwnd, &rect2); //冗長な計算・・・ wx += (rect1.right - rect1.left) - (rect2.right - rect2.left); wy += (rect1.bottom - rect1.top) - (rect2.bottom - rect2.top); px = ( int )((rc_desk.right - rc_desk.left) / 2) - ( int )(wx / 2) + rc_desk.left; py = ( int )((rc_desk.bottom - rc_desk.top) / 2) - ( int )(wy / 2) + rc_desk.top; //ウインドウを中央に配置する。 SetWindowPos(hwnd, HWND_TOPMOST, px, py, wx, wy, SWP_SHOWWINDOW); ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); MSG msg; while(GetMessage(&msg, NULL, 0, 0)) { Sleep(10); TranslateMessage(&msg); DispatchMessage(&msg); } return( msg.wParam ); }
- Syntax high-light テスト
before
<div class="sidebar"> <hatena name="searchform" template="hatena-module"> <hatena name="calendar2" template="hatena-module"> <hatena name="photo" template="hatena-module"> <hatena name="comment" template="hatena-module"> <hatena name="trackback" template="hatena-module"> <hatena name="antenna" template="hatena-module"> <hatena name="groupantenna" template="hatena-module"> <hatena name="calendar2photo" template="hatena-module"> <hatena name="section" template="hatena-module"> <hatena name="sectioncategory" template="hatena-module"> <hatena name="pv" template="hatena-module"> <div class="hatena-module"> <div class="hatena-moduletitle">リンク集</div> <div class="hatena-modulebody"> <ul class="hatena-urllist"> <li><a href="http://www.hatena.ne.jp/">はてな</a></li> <li><a href="http://g.hatena.ne.jp/">はてなグループ</a></li> </ul> </div> </div> </div>