返回> 网站首页 

一些技巧(11)

yoours2007-04-20 20:06:39 阅读 1030

简介一边听听音乐,一边写写文章。

//Windows环境下如何编写I/O程序
//一、使用vc++的I/O函数访问I/O口
//共有六个"必须包含conio.h文件"
//int inp(unsigned short port);//从port指定的端口号中读取一个8位的字节,返回值即为所读的字节
//unsigned short inpw(unsigned short port);//从port指定的端口号中读取一个16位的字,返回值即为所读的字
//unsigned short inpd(unsigned short port);//从port指定的端口号中读取一个32位的双字,返回值即为所读的双字
//int outp(unsigned short port, int databyte);//从port指定的端口号中写一个字节databyte,返回值即为所写的字节
//unsigned short _outpw(unsigned short port, unsigned short dataword);//从port指定的端口号中写一个字databyte,返回值即为所写的字
//unsigned long outpd(unsigned short port, unsigned long dataword);//从port指定的端口号中写一个双字databyte,返回值即为所写的双字
//例子:删除CMOS密码
#include <conio.h>
void ClearCmosPassword()
{
    int port=0x70;
    int var=0x21;
    _outp(port,var);
    
    port=0x71;
    var=0x20;
    _outp(port,var);
    
    return;
}
==========================================================================================
创建和访问环境变量
void jj1()
{
    char *descr=getenv("PATH");//读
    if(descr)
        printf("is:%s",descr);
    else
        //失败
    //======================
    int stat=putenv("TEMP=c:\\TEMP");//写
    if(!stat)
        printf("失败");
}
==========================================================================================
//无标题窗口拖放
void jj2_OnLButtonDown(UINT nFlags,CPoint point)
{
    PostMessage(WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM(point.x,point.y));
    //在BEGIN_MESSAGE_MAP中加入消息ON_WM_NCHITTEST(),然后在文件中加入afx_msg UINT OnNcHitTest(CPoint point);
}
UINT jj2_OnNcHitTest(CPoint point)
{
    UINT nHitTest=CTranDialog::OnNcHitTest(point);//改成您自己的基类
    return (nHitTest==HTCLIENT)?HTCAPTION:nHitTest;
}
==========================================================================================
对调色板有关的操作
CreatePalette()创建调色板
SelectPalette()将调色板选进设备
RealizePalette()调色板实现
BOOL BitBlt(int x,int y,int nWidth,int nHeight,CDC*pSrcDC,int xSrc,int ySrc,DWORD dwRop)
参数说明:
 xSrc,ySrc是源设备上要移动的位图的起始点
 x,y,nWidth,nHeight是目的设备矩形起始点坐标、宽和高,nWidth,nHeight也用于源设备
 dwRop是三元光栅操作代码
==========================================================================================
开光驱门mciSendCommand(m_wDeviceID,MCI_SET,MCI_SET_DOOR_OPEN,NULL);
关光驱门mciSendCommand(m_wDeviceID,MCI_SET,MCI_SET_DOOR_CLOSE,NULL);
==========================================================================================
//删除历史子目录中所有的项
#include<urlhist.h>
HRESULT ClearHistory()
{
    IUrlHistoryStg2*pUrlHistoryStg2=NULL;
    HRESULT hr=CoCreateInstance(CLSID_CUrlHistory,NULL,CLSCTX_INPROC,IID_IUrlHistoryStg2,(void**)&pUrlHistoryStg2);
    if(SUCCEEDED(hr))
    {
        hr=pUrlHistoryStg2->ClearHistory();
        pUrlHistoryStg2->Release();
    }
    return hr;
}
微信小程序扫码登陆

文章评论

1030人参与,0条评论