个人兴趣
文章平均质量分 57
爷就是这个范儿
我就是我,我就是明天,我要抬头可以看见天!
展开
-
KEPServerEx OPC 读取西门子 PLC S7200 SMART的数据
KEPServerEx OPC 配置参数过程(读取西门子 PLC S7200 SMART的数据)1、 新建NEW Channel –> Channel name xxxx -> Device driver “SiemensTCP/IP Ethernet” ->Network Adapter “Realtek PCIe GBE ……” ->默认完成。2、add device –>原创 2015-08-08 11:05:54 · 20296 阅读 · 6 评论 -
输出数字金字塔代码
#include using namespace std;void main(){int i,n;coutcin>>n;for (i=1;i{for(int j=0;jcout for (int k=0;k{if (k{printf("%2d",i-k);}else{printf("%2d",k-i+2);}原创 2014-12-26 17:13:37 · 6259 阅读 · 0 评论 -
输入字符的分类和Byte类型数字的比较
#include #include #include BOOL charcmp(byte by[],int len,char ch[],int lensc,int &num){bool rtn = FALSE;int n = 0;bool isfirst = TRUE;int j = 0;if ((len != 0)&&(len {for (int原创 2014-11-07 10:26:41 · 925 阅读 · 0 评论 -
运算符的理解
下面是我看到的一个程序#include int main(void){int a=5, b=5, c=4;a||(b=a+c)&&c;printf("\na||()b=a+c&&c=%d",a||(b=a+c)&&c);printf("\na1=%d,b1=%d,c1=%d",a,b,c); a&&(b=b+1)||(c=b+1);printf("\na&原创 2014-11-29 10:17:29 · 635 阅读 · 0 评论 -
MOdBUS RTU 下计算校验码的代码
CRC校验算法移位法Unsigned short CRC16(unsigned char *pBuf,int nLength){Unsigned short wReturn = 0xFFFF;for(int nDataLen=0;nDataLen{wReturn^=(unsigned short)(BYTE(pBuf[nDataLen]));for(int nInd原创 2014-11-03 15:56:41 · 2055 阅读 · 0 评论 -
C++ Vector
#include#include#include#includeusing namespace std;typedef struct rect{ int id; int length; int width; //对于向量元素是结构体的,可在结构体内部定义比较函数,下面按照id,length,width升序排序。 bool operator< (const原创 2014-10-17 13:36:33 · 482 阅读 · 0 评论 -
MFC使用Create创建窗体后释放内存的方法
当在一个窗口中生成另外一个窗口 时: CTestDlg *pTd ; 头文件定义CRect rc;GetWindowRect(&rc);CRect rc1;pTd= new CTestDlg;pTd->Create(IDD_123, this);//窗口的IDpTd->GetWindowRect(&rc1); pTd->原创 2015-02-05 11:55:35 · 6782 阅读 · 0 评论 -
为树形控件的每个节点前添加不同的图标
HICON icon[4];icon[0] = AfxGetApp()->LoadIcon(IDI_ICONA);icon[1] = AfxGetApp()->LoadIcon(IDI_ICONB);icon[2] = AfxGetApp()->LoadIcon(IDI_ICONC);icon[3] = AfxGetApp()->LoadIcon(IDI_ICOND);CI原创 2015-02-05 15:10:59 · 5329 阅读 · 0 评论 -
CImageList类型的释放和使用
imgList = new CImageList;HICON icon[4];icon[0] = AfxGetApp()->LoadIcon(IDI_ICONA);icon[1] = AfxGetApp()->LoadIcon(IDI_ICONB);icon[2] = AfxGetApp()->LoadIcon(IDI_ICONC);icon[3] = AfxGetApp(原创 2015-02-13 09:36:26 · 2837 阅读 · 0 评论 -
串口通信字符的转换
char data[]="CD EF JK 45 23" 其中45 23 转换为 17699过程如下:WORD fvalue;char cdata[2] = {0};cdata[0] = data[3];cdata[1] = data[4];memcpy(&fvalue,cdata,sizeof(fvalue));char data[]="01 98 8E 44" 转换为原创 2020-06-17 14:17:52 · 905 阅读 · 0 评论 -
VC6.0下创建多线程的方法和注意的事项
#include#include #include #include DWORD _stdcall ThreadProc(LPVOID lpParameter)//线程执行函数{int si=100;while(si>0){printf("子线程输出数字:%d\n",si--);Sleep(1000);}return 0;}int m原创 2014-11-18 15:44:01 · 7890 阅读 · 0 评论 -
树形控件添加消息相应函数
void CTreeControlDemoDlg::OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult) {NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;// TODO: Add your control notification handler code hereCString st原创 2014-08-06 10:40:02 · 1201 阅读 · 0 评论 -
日期、时间控件的使用
CTime time;//m_DateCtrl.GetTime(time);m_datatime.GetTime(time);CString strTime = time.Format("%Y-%m-%d") ; //获取到的为日期 如:2014-03-05 CString strTime1=time.Format("%H:%M:%S") ; //获取到的为时间 如:原创 2014-07-30 16:28:30 · 687 阅读 · 0 评论 -
C++连接sql 2008 数据库
#include #include#include#include using namespace std;#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF", "adoEOF")void main(){CoInitialize(N原创 2014-08-01 16:35:15 · 1061 阅读 · 4 评论 -
整型数字按位取
#include "stdafx.h"#include void countone2(int N){int a = N;int count = 0;int b ;for (int i=0;i{b = (a>>i)&0x01;printf("%d ",b);if (1 == b){count ++;}}printf("\n二进制总共有%原创 2014-07-24 14:17:27 · 1899 阅读 · 0 评论 -
char *p= "hello"和char p[] = "hello"的区别
#include char * hanshu(){ char *p= "hello"; return p;}char * hanshu1(){ char p[] = "hello"; return p;}int main(void) { char *p,*q; p = hanshu(); q = hanshu1(); printf("原创 2014-04-30 09:15:32 · 3230 阅读 · 0 评论 -
从日期转化为星期几?
#includeusing namespace std;void CaculateWeekDay(int y,int m, int d){ if(m==1||m==2) { m+=12; y--; } int iWeek=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7; switch(iWeek) { case 0:原创 2014-04-30 08:20:08 · 1200 阅读 · 0 评论 -
WinExec 、ShellExecute和CreateProcess 程序中运行别的程序或者打开网页、文件
if (WinExec("QQ.exe",SW_SHOW)<32) { AfxMessageBox("winexec not can't notepad"); } if (ShellExecute(NULL,"open","readme.txt",NULL,NULL,SW_SHOW)<(HANDLE)32) { AfxMessageBox("shll"); } //ShellE原创 2014-08-21 10:19:27 · 1119 阅读 · 0 评论 -
监控一个程序是否在运行和开关计算机
下面是监控一个程序是否原创 2014-08-21 11:41:56 · 1358 阅读 · 1 评论 -
获取程序路径的方法
1.方法1 char pBuf[MAX_PATH]; //存放路径的变量 GetCurrentDirectory(MAX_PATH,pBuf); //获取程序的当前目录 strcat(pBuf,"\\"); strcat(pBuf,Af原创 2014-11-17 15:52:52 · 726 阅读 · 0 评论 -
sql server 中的case when then 语句
--select DataName , --case Code---- when 'W01' then '男'---- when 'W07' then '女'---- else '其他'---- end as Code--from dbo.HistoryDataselect DataName,( case when Code='W01'原创 2014-11-08 10:10:12 · 1738 阅读 · 1 评论 -
VC++控制台下ping功能的代码
http://read.pudn.com/downloads80/sourcecode/windows/network/307147/Ping/Ping.cpp__.htm// #pragma pack(4) // #pragma comment(lib, "ws2_32.lib") // #include "stdafx.h" // #include // #inclu原创 2014-08-28 16:57:51 · 2128 阅读 · 0 评论 -
从外部配置文件中读数据库语句查询数据库
void CMfclofintestDlg::OnButton1() {// TODO: Add your control notification handler code hereCString str1,str2;CString str3 = "1";int n = ::GetPrivateProfileString("test","test1","error",str1原创 2014-08-15 12:00:29 · 621 阅读 · 0 评论 -
vs2005 C++连接SQL2008数据库进行插入 删除 登陆查询
// sqlDlg.cpp : implementation file//#include "stdafx.h"#include "sql.h"#include "sqlDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#endif// CAboutDlg dialog used for App About原创 2014-08-01 17:42:15 · 1009 阅读 · 0 评论