zoukankan      html  css  js  c++  java
  • Windows API SystemParametersInfo函数

    面对华丽的Windows桌面,工作的心情或许好很多,但是久了总会失去兴趣,总想定期地更新桌面的图片。软件开发人员又面对这样的需求了,需要怎么样去做呢?努力去找API函数吧。到目前为止,还有很多变桌面图片的软件,并且还能很挣钱的。其实设置桌面图片的需求,在目前数码相片处理软件也有现实的需求,比如当你去旅游回来后,想把照片当作桌面图片,就可以在处理图片时就设置为桌面图片。这样就需要使用函数SystemParametersInfo来完成这项工作了,当然这个函数还有很多其它功能,比如获取桌面工作区的大小。
     
    函数SystemParametersInfo声明如下:
    WINUSERAPI
    BOOL
    WINAPI
    SystemParametersInfoA(
        __in UINT uiAction,
        __in UINT uiParam,
        __inout_opt PVOID pvParam,
        __in UINT fWinIni);
    WINUSERAPI
    BOOL
    WINAPI
    SystemParametersInfoW(
        __in UINT uiAction,
        __in UINT uiParam,
        __inout_opt PVOID pvParam,
        __in UINT fWinIni);
    #ifdef UNICODE
    #define SystemParametersInfo SystemParametersInfoW
    #else
    #define SystemParametersInfo SystemParametersInfoA
    #endif // !UNICODE
     
    uiAction是作不同的操作参数。
    uiParam是设置的参数。
    pvParam是设置或返回的参数。
    fWinIni是设置的参数。
     
    调用函数的例子如下:
    #001 //
    #002  //获取系统配置信息。
    #003  //蔡军生 2007/11/16 QQ:9073204 深圳
    #004  void GetSystemParam(void)
    #005  {
    #006         //获取桌面墙纸的路径。
    #007         //SPI_GETDESKWALLPAPER
    #008         TCHAR chPath[MAX_PATH];
    #009        if (SystemParametersInfo(SPI_GETDESKWALLPAPER,MAX_PATH,chPath,0))
    #010         {
    #011               //
    #012               OutputDebugString(chPath);
    #013               OutputDebugString(_T(""r"n"));
    #014         }
    #015 
    #016         //获取工作区的大小。
    #017         //SPI_GETWORKAREA
    #018         RECT rcWorkArea;
    #019        if (SystemParametersInfo(SPI_GETWORKAREA,0,&rcWorkArea,0))
    #020         {
    #021               //
    #022               const int nBufSize = 256;
    #023               TCHAR chBuf[nBufSize];
    #024 
    #025               wsprintf(chBuf,_T("%u,%u,%u,%u"),rcWorkArea.left,rcWorkArea.top,
    #026                    rcWorkArea.right,rcWorkArea.bottom);
    #027              
    #028               OutputDebugString(chBuf);
    #029               OutputDebugString(_T(""r"n"));
    #030         }
    #031 

    #032  }

    delphi 代码

    var rcWorkArea: TRect;

    begin

      SystemParametersInfo(SPI_GETWORKAREA,0, Pointer(@rcWorkArea), 0);

      szTmp1 := Format( 'Left: %d top: %d  Right: %d bottom: %d ',
               [rcWorkArea.Left, rcWorkArea.Top, rcWorkArea.Right, rcWorkArea.Bottom]);

      Caption := szTmp1;

    end;


  • 相关阅读:
    使用类的静态字段和构造函数,我们可以跟踪某个类所创建对象的个数。请写一个类,在任何时候都可以向它查询“你已经创建了多少个对象?”。
    《大道至简》第三章读后感
    动手动脑
    zencart设置特价商品价格
    如何设置zencart买满多少免运费?
    zencart分类页每页显示产品数量自定义选择的方法
    Access数据库LIKE问题
    zencart清空产品商品实用命令
    dedecms织梦后台发布文章提示“标题不能为空”的解决办法
    zencart重置用户登录密码sql
  • 原文地址:https://www.cnblogs.com/chenhs/p/1333196.html
Copyright © 2011-2022 走看看