WinAPI 123

-- ZoomQuiet [2004-12-22 10:39:08]

使用 WinAPI 的例子

>>> import hidewin
>>> hidewin.hide(1)  # 隐藏 状态条
0
>>> hidewin.hide(0)  # 显示状态条
0
>>> 

C 语言源程序

: hidewin.c

#include <windows.h>

int hide(int flag)
{
        HWND hShellTray = FindWindow("Shell_TrayWnd",NULL);
        if(flag == 1)
        {
                ShowWindow(hShellTray,SW_HIDE);
        }
        else
        {
                ShowWindow(hShellTray,SW_SHOW);
        }
        return 0;
} 

swig 配置文件

%module hidewin
%{
%}

extern int hide(int flag);

编译与安装步骤

  1. 安装 swig (请看其他文档)
  2. swig.exe -python hidewin.i
    • (生成 hidewin_wrap.c hidewin.py 两个文件)
  3. 在 VC 中建立 Win32 DLL 工程,把 hidewin_wrap.c 以及 hidewin.c 加入工程, 设置 Python 头文件,及库文件目录
  4. 编译 生成 _hidewin.dll
  5. ok, 在这个目录中可以执行 python解释器 使用了,使用见上面的例子
  6. 或者把 hidewin.py _hidewin.dll 两个文件放到Python安装目录的lib目录下,就可以了。

PyTips/PyWinApi (last edited 2009-12-25 07:09:08 by localhost)