随着计算机网络化的深入,计算机网络编程在程序设计的过程中变得日益重要。许多文章都曾经介绍过用VC++进行Socket编程的方法。但由于都是直接利用动态连接库wsock32.dll进行操作,实现比较繁琐。其实,VC++的MFC类库中提供了CAsyncSocket这样一个套接字类,用它来实现Socket编程,是非常方便的。
客户端
创建一个Dialog Based项目:CSockClient。设计一对话框,增加ID_Connect(连接)、ID_Send(发送)、ID_Exit(关闭)按钮,增加ListBox控件IDC_LISTMSG和Edit控件IDC_EDITMSG...
//1:显示文件进度
//2:可以随时终止传输过程
//发送数据线程
UINT SendDataThread(LPVOID lpParam);
//接收数据线程
UINT ReceiveDataThread(LPVOID lpParam);
//发送数据按钮消息响应函数
void CTzg004Dlg::OnButtonSend()
{
// TODO: Add your control notification handler code here
//初始化数据发送结束标志
m_bSendEnd=FALSE;
//...
Windows系统是建立在事件驱动的机制上的,说穿了就是整个系统都是通过消息的传递来实现的。而钩子是Windows系统中非常重要的系统接口,用它可以截获并处理送给其他应用程序的消息,来完成普通应用程序难以实现的功能。钩子可以监视系统或进程中的各种事件消息,截获发往目标窗口的消息并进行处理。这样,我们就可以在系统中安装自定义的钩子,监视系统中特定事件的发生,完成特定的功能,比如截获键盘、鼠标的输入,屏幕取词,日志监视等等。可见,利用钩子可以实现许多特殊而有用的功能。因此,对于高级编程人员来说,掌握钩子的编程方法是很有必要的。钩子的类型 一. 按事件分类,有如下的几种常用类型 (1)...
1、静态链接使用该方法,必须制定要链接的lib文件。和接口说明的*.h文件
2、动态链接该方法用LoadLibrary载入dll,并且使用GetProcAddress得到dll中允许应用程序调用的函数的地址在最后还要释放该dll:FreeLibrary
DllHmodule = LoadLibrary("H:\\MyVC\\your.dll"); if( !DllHmodule ) { AfxMessageBox("调用Dll失败!"); CDialog::OnOK(); }
YOURFUNCDEFINE MyFunc = (YOURFUNCDEFINE)GetProcA...
mciSendString是用来播放多媒体文件的API指令,可以播放MPEG,AVI,WAV,MP3,等等,下面我们来介绍一
下它的使用方法:
一,打开多媒体文件。
首先在Dialog上面放一个Picture控件,MCISendString就在这个Picture控件的平面上播放多媒体文件,
设Picture控件的ID为IDC_STATIC1:
CStatic *pStatic=(CStatic*)GetDlgItem(IDC_STATIC1);HWND h=pStatic->GetSafeHwnd();
CString open1;
...
问题如下:我定义了如下的一个结构体:typedef struct{  CString csText;}MyStruct;并有如下的程序段1:MyStruct * p=NULL;p=(MyStruct *)malloc(sizeof(MyStruct));if(!p)   AfxMessageBox("分配内存失败!");else{    p->csText="hello world!";    free(p);}执行程序段1,会出现一个内存读取异常,系统提示程序非法read了一个...
#include <iostream>
#include <list>
using namespace std;
int map[9][9]={
4,0,0,0,0,2,0,0,9,
9,5,8,0,0,3,7,0,0,
2,0,7,5,0,0,4,0,0,
0,0,0,0,0,0,0,1,0,
1,9,2,0,3,0,0,4,5,
0,4,0,0,0,0,0,0,0,
0,0,9,0,0,6,2,0,4,
0,2,4,3,0,0,8,9,6,
6,0,0,2...
刚刚申请了一个C语言论坛的名额,是新手,初学者,希望各位哥哥姐姐不吝赐教啊!
一、CGI概述 CGI(公用网关接口)规定了Web服务器调用其他可执行程序(CGI程 序)的接口协议标准。Web服务器通过调用CGI程序实现和Web浏览器的 交互,也就是CGI程序接受Web浏览器发送给 Web服务器的信息,进行处 理,将响应结果再回送给Web服务器及Web浏览器。CGI程序一般完成We b网页中表单(Form)数据的处理、数据库查询和实现与传统应用系统 的集成等工作。CGI程序可以用任何程序设计语言编写,如Shell脚本 语言、Perl、Fortran、Pascal、C语言等。但是用C语言编写的CGI程 序具有执行速度快、安全性高(因为C语言程序是编译执行且不可...
#include <stdio.h>
#define OUT 0 /* outside word */
#define IN 1 /* inside word */
int main(void)
{
int c, nw;
nw = 0;
while((c = getchar()) != EOF)
{
while ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
;
+...
我想学好编程 可是没有英语基础 请问我要怎么要学好C语言呢
是不是要买些参考书 但是我要买什么样的参考书呢
#include <stdio.h>
int main(void){ int num, baiwei, shiwei, gewei, i, j; i = j = 0; for (num = 100; num < 999 ; ++num) { baiwei = num / 100; shiwei = (num - baiwei*100) / 10; gewei = num - baiwei*100 - shiwei *10; if ((baiwei != shiwei) && (ba...
/* Write a program to copy its input to its output,replacing each tab by \t, *each backspace by \b,and each backslash by \\ .This makes tabs and backspaces *visible in an unambiguous way */ #include <stdio.h> int main(void) { int c; while ((c = getchar()) != EOF) { if...
/*Write a program to copy its input to its output, *replacing each string of one or more blanks by a single blank*/#include <stdio.h>
#define OUT 1 /* outside the word */#define IN 0 /* inside the word */
int main(void){ int c,state; state = OUT; while ((c = getchar()) != EO...
/* Write a program to count blanks,tabs,and newlines */
#include <stdio.h>
int main(void)
{
int c, nb, nt, nn;
nb = nt = nn = 0;
while((c = getchar()) != EOF)
{
if (c == ' ') ++nb;
if (c == '\t') ++nt;
if (c == '\n') ++nn;
}
print...
/* 1st version */
#include <stdio.h>
int main(void)
{
int c, nl;
nl = 0;
while ((c = getchar()) != EOF)
if (c == '\n')
++nl;
printf("%d",nl);
getch();
return 0;
}
===========================
/* 2nd version */
#include <stdio.h...
/* 1st version */
#include<stdio.h>
int main(void)
{
int c, nc;
nc = 0;
while((c = getchar()) !=EOF)
{
++nc;
}
printf("%d",nc);
getch();
return 0;
}
======================
/* 2nd version */
#include <stdio.h>
int main(v...
/* Write a program to print the value of EOF */
/* 1st version */
#include <stdio.h>
int main(void){ int c;
c = EOF;
printf("the value of EOF is %d",c);
getch(); return 0;}
===============/* 2nd version */
#include <stdio.h>
int main(void){ printf("...
/* 1st verion.copy input to output */
#include <stdio.h>
int main (void){ int c;
c = getchar(); while (c != EOF) { putchar(c); c = getchar(); }
return 0;}
===========================
/* 2ed version.copy input to output */
#include <stdio.h>
...
/* The version of symbolic constants : print Fahrenheit-celsious table */
#include<stdio.h>
#define LOWER 0#define UPPER 300#define STEP 20
int main(viod){ float fahr;
for (fahr = LOWER; fahr <= UPPER; fahr += STEP ) { printf("%3.0f%6.1f\n", fahr, (5.0/9.0) * ( f...