初识Wine

初识Wine

Wine是什么?它是一个Windows系统在LinuxUnix系统上的实现,它实现了基本上所有的Windows API,并且都有源代码,当你对DispachMessagePeekMessage的实现想弄个究竟或是自己设计一个类似Windows的消息系统等等等时,那就可以看看研究一下Wine的实现了!看看Wine官网的介绍(http://www.winehq.org/):

Wine is an Open Source implementation of the Windows API on top of X, OpenGL, and Unix.

Think of Wine as a compatibility layer for running Windows programs. Wine does not require Microsoft Windows, as it is a completely free alternative implementation of the Windows API consisting of 100% non-Microsoft code, however Wine can optionally use native Windows DLLs if they are available. Wine provides both a development toolkit for porting Windows source code to Unix as well as a program loader, allowing many unmodified Windows programs to run on x86-based Unixes, including Linux, FreeBSD, Mac OS X, and Solaris.

More information can be read in the articles Why Wine is so important, and Debunking Wine Myths. If you are wondering how well a particular application works in Wine, please examine the Applications Database. For installation instructions and step-by-step help with running Wine, take a look at the User Guide.

Wine is free software. The licensing terms are the GNU Lesser General Public License.

预览一下效果图,LotusLinux上运行的效果:

 

下载Winesource code,建立了一个Source Inside Project,开始查看其代码,帖一个DispatchMessage codesnippet

BOOL WINAPI TranslateMessage( const MSG *msg )

{

    UINT message;

    WCHAR wp[2];

    BYTE state[256];

 

    if (msg->message < WM_KEYFIRST || msg->message > WM_KEYLAST) return FALSE;

    if (msg->message != WM_KEYDOWN && msg->message != WM_SYSKEYDOWN) return TRUE;

 

    TRACE_(key)("Translating key %s (%04lx), scancode %02x/n",

                 SPY_GetVKeyName(msg->wParam), msg->wParam, LOBYTE(HIWORD(msg->lParam)));

 

    GetKeyboardState( state );

    /* FIXME : should handle ToUnicode yielding 2 */

    switch (ToUnicode(msg->wParam, HIWORD(msg->lParam), state, wp, 2, 0))

    {

    case 1:

        message = (msg->message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;

        TRACE_(key)("1 -> PostMessageW(%p,%s,%04x,%08lx)/n",

            msg->hwnd, SPY_GetMsgName(message, msg->hwnd), wp[0], msg->lParam);

        PostMessageW( msg->hwnd, message, wp[0], msg->lParam );

        break;

 

    case -1:

        message = (msg->message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR;

        TRACE_(key)("-1 -> PostMessageW(%p,%s,%04x,%08lx)/n",

            msg->hwnd, SPY_GetMsgName(message, msg->hwnd), wp[0], msg->lParam);

        PostMessageW( msg->hwnd, message, wp[0], msg->lParam );

        break;

    }

    return TRUE;

}

 

慢慢看,学习一下,对windowsliux系统的编程都有很好的帮助,Go!

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值