2009年3月31日星期二

有趣的HTA程序






有趣的HTA程序

下面的脚本是采用Javascript

    1 <head>
    2 <title>Hello World</title>
    3 <hta:application 
    4      applicationname="helloworld"
    5      scroll="no"
    6      border="5pt"
    7      borderstyle="raised"
    8      maximizebutton="yes"
    9      minimizebutton="yes"
   10      showintaskbar="yes"
   11      caption="yes"
   12      sysmenu="yes"
   13      singleinstance="yes"
   14 >
   15 </head>
   16 
   17 <script>
   18     function test(){
   19         alert ("Hello World");
   20     }
   21 </script>
   22 
   23 <body>
   24 <input type="button" value="Run Script" onClick="test()"><p> 
   25 </body>

这里的脚本采用vbscript

    1 <head>
    2 <title>Hello World</title>
    3 <hta:application 
    4      applicationname="helloworld"
    5      scroll="no"
    6      border="5pt"
    7      borderstyle="raised"
    8      maximizebutton="yes"
    9      minimizebutton="yes"
   10      showintaskbar="yes"
   11      caption="yes"
   12      sysmenu="yes"
   13      singleinstance="yes"
   14 >
   15 </head>
   16 
   17 <script language="VBScript">
   18     sub test
   19         msgbox "Hello World", vbExclamation, "Hello World"
   20     end sub
   21 </script>
   22 
   23 <body>
   24 <input type="button" value="Run Script" onClick="test"><p> 
   25 </body>

程序运行后的界面


2009年3月26日星期四

构造微小的EXE程序






构造微小的EXE程序

本文参考了网上的帖子《VC++下编译极小的程序》,《VC8中打造512字节超小应用程序》。废话不用说,直接上两个例子:

例子一: 一个Console程序


    1 #include <windows.h>
    2 
    3 #pragma comment(lib, "User32")
    4 #pragma comment(lib, "Kernel32")
    5 #pragma comment(linker, "/Entry:main")
    6 #pragma comment(linker, "/Merge:.rdata=.text")
    7 
    8 bool WINAPI StdOut( LPCTSTR lpString)
    9 {
   10     HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
   11     DWORD numOfCharsWritten=0;
   12     return WriteConsole(hStdOut, lpString, lstrlen(lpString), &numOfCharsWritten, NULL);
   13 }
   14 
   15 int main()
   16 {
   17     TCHAR *pChar = TEXT("Hello World!\n");
   18     StdOut(pChar);
   19 }


采用VC9命令行编译 cl minic.cpp /link /align:16,编译后大小为768 byte。


例子二: 一个窗口程序


    1 #include <windows.h>
    2 
    3 #pragma comment (lib,"user32.lib")
    4 #pragma comment (lib,"kernel32.lib")
    5 #pragma comment(linker, "/Entry:main")
    6 #pragma comment(linker, "/Merge:.rdata=.text")
    7 #pragma comment(linker, "/Subsystem:windows")
    8 
    9 void *operator new[](unsigned int size){
   10     return HeapAlloc (GetProcessHeap(), NULL, size);
   11 }
   12 
   13 void operator delete[] (void* memblock){
   14     HeapFree (GetProcessHeap(), NULL, memblock);
   15 }
   16 
   17 void main ()
   18 {
   19     TCHAR* str = new TCHAR[250];
   20     wsprintf (str, TEXT("The system has run %d\n"), GetTickCount());
   21     MessageBox (NULL,str,str,MB_ICONINFORMATION);
   22     delete[] str;
   23 }


采用VC9命令行编译 cl msgbox.cpp /link /align:16,编译后大小为944 byte。




2009年3月25日星期三

如何安装WindowXP到S10E

如何安装WindowXP到S10E

1. 下载DEEPIN PE V3.ISO 或者 BootCD_070911.RAR.
用UltraISO将PE映像到USB盘上。
2. 下载DEEPIN-LITEXP-6.2.ISO从中取出GHOSTEXP.GHO到USB盘上, 同时需要拷贝GHOST32.EXE
3. 使用这个USB来启动机器进入WINDOWS PE。
4. 可用WINDOWS PE 带的磁盘管理工具给硬盘分区,可能会需要重启
5. 启动Ghost32将System.gho恢复到硬盘中。也可以使用PE的在命令行下执行ghost32 -sure -rb -clone,mode=pload,src="ghostxp.gho:1",dst=1:1。
它的作用是把当前文件夹下的ghostxp.gho文件恢复到第一块硬盘的第一个分区上,并且无需确认,在操作完成后自动重新启动计算机。

Visual Studio 的字体及配色































Visual Studio 的字体及配色

有一个很好的网站 "Is your IDE Hot or Not", http://idehotornot.ning.com/,里面有很多很好的配色方案。
还有一个博客写得也很不错 http://www.codinghorror.com/blog/archives/000682.html

TIPS
1. 打开Clear Type选项
Windows XP中为了增强LCD显示器的显示效果,添加了一种名为Clear Type的技术。打开这种技术后屏幕上显示的字符会更加好看。在桌面空白处点击鼠标右键,选择属性,然后打开显示属性的外观选项卡,并点击效果按钮,选中 “使用下列方式使屏幕字体的边缘更加平滑”,然后在下拉菜单中选择清晰。这时Clear Type就被打开了。

2. 编程常用的字体
在网上搜索了一下,常用的字体包括Fixedsys (点阵字体), Consolas, Courier New, Bitstream vera sans Mono, Monaco等

3. 将Visual Studio的source变成html的插件: CopySourceAsHtml (CSAH)
http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/.

(还有一个Firefox的插件用于将代码变成html,非常不错,https://addons.mozilla.org/zh-CN/firefox/addon/11086, http://code.google.com/p/hightlight-extension/)

4. 不要忘了VS2008的搭档Visual assist 1647






    1 #pragma once
    2 #include "Shape_h.h"
    3 #include <objbase.h>
    4 #include <atlbase.h>
    5 #include <atlcom.h>
    6 #include <atlstr.h>
    7 #include <iostream>
    8 
    9 //  IShapeImp
   10 template <class C, const CLSID* pclsid, class T, const GUID* plibid>
   11 class ATL_NO_VTABLE IShapeImpl :
   12     public CComObjectRootEx<CComSingleThreadModel>,
   13     public CComCoClass<C, pclsid>,
   14     public IDispatchImpl<T, &__uuidof(T), plibid>
   15 {
   16 public:
   17     STDMETHOD(get_desc)(BSTR *pVal){
   18         CString szShape = L"Shape";
   19         *pVal = szShape.AllocSysString();
   20         return S_OK;
   21     }
   22 
   23     STDMETHOD(draw)(){return E_NOTIMPL;};
   24     STDMETHOD(get_area)(double* area){return E_NOTIMPL;};
   25 };

这个采用了Midtone Scheme v1.vssettings.


http://idehotornot.ning.com/index.php/index/show?id=2227069

    1 #pragma once
    2 #include "Shape_h.h"
    3 #include <objbase.h>
    4 #include <atlbase.h>
    5 #include <atlcom.h>
    6 #include <atlstr.h>
    7 #include <iostream>
    8 
    9 //  IShapeImp
   10 template <class C, const CLSID* pclsid, class T, const GUID* plibid>
   11 class ATL_NO_VTABLE IShapeImpl :
   12     public CComObjectRootEx<CComSingleThreadModel>,
   13     public CComCoClass<C, pclsid>,
   14     public IDispatchImpl<T, &__uuidof(T), plibid>
   15 {
   16 public:
   17     STDMETHOD(get_desc)(BSTR *pVal){
   18         CString szShape = L"Shape";
   19         *pVal = szShape.AllocSysString();
   20         return S_OK;
   21     }
   22 
   23     STDMETHOD(draw)(){return E_NOTIMPL;};
   24     STDMETHOD(get_area)(double* area){return E_NOTIMPL;};
   25 };

这个采用了zenburn-scheme.vssettings
Description: Dark background with low contrast highlighting.

http://www.codinghorror.com/blog/archives/000682.html
或者
http://idehotornot.ning.com/index.php/index/show?id=2044686

还有一个升级版本,支持CSS,HTML和ASP
http://idehotornot.ning.com/index.php/index/show?id=2353062






    1 #pragma once
    2 #include "Shape_h.h"
    3 #include <objbase.h>
    4 #include <atlbase.h>
    5 #include <atlcom.h>
    6 #include <atlstr.h>
    7 #include <iostream>
    8 
    9 //  IShapeImp
   10 template <class C, const CLSID* pclsid, class T, const GUID* plibid>
   11 class ATL_NO_VTABLE IShapeImpl :
   12     public CComObjectRootEx<CComSingleThreadModel>,
   13     public CComCoClass<C, pclsid>,
   14     public IDispatchImpl<T, &__uuidof(T), plibid>
   15 {
   16 public:
   17     STDMETHOD(get_desc)(BSTR *pVal){
   18         CString szShape = L"Shape";
   19         *pVal = szShape.AllocSysString();
   20         return S_OK;
   21     }
   22 
   23     STDMETHOD(draw)(){return E_NOTIMPL;};
   24     STDMETHOD(get_area)(double* area){return E_NOTIMPL;};
   25 };



这个采用了jheidt_tones_2008_v1.vssettings

Pill Crusher 2008


http://idehotornot.ning.com/index.php/index/show?id=12174264