#include <windows.h>
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd )
{
OPENFILENAME ofn;
//在内存中开辟一块空间,存放用户选取的文件名
char szFile[MAX_PATH];//MAX_PATH是系统定义的一个宏值为260,Windows操作系统文件路径的最大长度
ZeroMemory(&ofn,sizeof(ofn));//将这个结构体变量定义为0
ofn.lStructSize = sizeof(ofn);//获取结构体的大小
ofn.lpstrFile = szFile;//szFile是一个字符数组,那么szFile这个名字就代表这个字符数组的首地址这是一个指针的应用,把接收选择文件名的数组的地址传递到GetOpenFileName函数中。
ofn.lpstrFile[0] = TEXT('\0');//效果等价于ZeroMemory(szFile,sizeof(szFile));
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = TEXT("所有文件(*.*)\0*.*\0Text(*.TXT)\0*.TXT\0");
ofn.nFilterIndex = 1;//默认选择的过滤器,索引从1开始
// 指向接收选择的文件的文件名和扩展名的缓冲(不带路径信息)。这个成员可以是NULL。
of ......
#include <windows.h>
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd )
{
OPENFILENAME ofn;
//在内存中开辟一块空间,存放用户选取的文件名
char szFile[MAX_PATH];//MAX_PATH是系统定义的一个宏值为260,Windows操作系统文件路径的最大长度
ZeroMemory(&ofn,sizeof(ofn));//将这个结构体变量定义为0
ofn.lStructSize = sizeof(ofn);//获取结构体的大小
ofn.lpstrFile = szFile;//szFile是一个字符数组,那么szFile这个名字就代表这个字符数组的首地址这是一个指针的应用,把接收选择文件名的数组的地址传递到GetOpenFileName函数中。
ofn.lpstrFile[0] = TEXT('\0');//效果等价于ZeroMemory(szFile,sizeof(szFile));
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = TEXT("所有文件(*.*)\0*.*\0Text(*.TXT)\0*.TXT\0");
ofn.nFilterIndex = 1;//默认选择的过滤器,索引从1开始
// 指向接收选择的文件的文件名和扩展名的缓冲(不带路径信息)。这个成员可以是NULL。
of ......
//#include "stdafx.h"
/*
描述:纯c模拟类,纯c编写c++类,纯c实现c++类的简单范例,结构模拟类,struct 编写class.
c编写类是实现纯c编写com组件的基础。
*/
#include <stdio.h>
typedef struct _Vtbl
{
void (*AddRef)(struct CObject* obj,int);//所有的函数的第一个参数类似class的隐匿的this指针
void (*Release)(struct CObject* obj);
}Vtbl;//函数指针数组
typedef struct CObject
{
Vtbl vtbl;//函数指针数组指向成员函数
int a;
int b;
}Cobj;//结构模拟类的简单定义
void fun1(Cobj *obj,int count)//成员函数
{
obj->a+=count;
printf("CObject::a=%d\n",obj->a);
}
void fun2(Cobj *obj)//成员函数
{
obj->a--;
printf("CObject::a=%d\n",obj->a);
}
static Vtbl vt={fun1,fun2};//声明一个静态函数指针数组
int main()
{
Cobj obj;//定义对象
obj.vtbl=vt;
obj.a= 10 ......
//#include "stdafx.h"
/*
描述:纯c模拟类,纯c编写c++类,纯c实现c++类的简单范例,结构模拟类,struct 编写class.
c编写类是实现纯c编写com组件的基础。
*/
#include <stdio.h>
typedef struct _Vtbl
{
void (*AddRef)(struct CObject* obj,int);//所有的函数的第一个参数类似class的隐匿的this指针
void (*Release)(struct CObject* obj);
}Vtbl;//函数指针数组
typedef struct CObject
{
Vtbl vtbl;//函数指针数组指向成员函数
int a;
int b;
}Cobj;//结构模拟类的简单定义
void fun1(Cobj *obj,int count)//成员函数
{
obj->a+=count;
printf("CObject::a=%d\n",obj->a);
}
void fun2(Cobj *obj)//成员函数
{
obj->a--;
printf("CObject::a=%d\n",obj->a);
}
static Vtbl vt={fun1,fun2};//声明一个静态函数指针数组
int main()
{
Cobj obj;//定义对象
obj.vtbl=vt;
obj.a= 10 ......
http://www.ddj.com/cpp/221600722
Q: HOW DO I... put timers with default actions in my C code?
A: Many times, we need to write programs that will only wait a certain specified amount of time for a user to do something. After that time, we need to assume that the user isn't going to do anything and move on to some specified default action. This Snippet works exactly like the get_ch() function in most PC C compiler libraries, except that it will only wait as long as you tell it for the user to hit a key. If no key is pressed within the time limit, the function returns with an EOF. As usual, a test harness has been added to allow for stand-alone testing. To compile the stand-alone test, simply define the TEST macro.
/*
** TIMEGETC.C - waits for a given number of seconds for the user to press
** a key. Returns the key pressed, or EOF if time expires
**
** Public domain by Bob Jarvis
** Test harness added by Bob Stout
**
** Note: This relies on the non-standard ......
试验了好久,终于搞定了。
首先,必须有错误继续进行的声明On Error Resume Next
然后尝试简历jmail实例:
Dim JMail
Set JMail=Server.CreateObject("JMail.Message")
对实例做出判断,如果组件没有安装成功,则没有创建实例:
If JMail Is Nothing Then
Response.Write "不支持"
Else
Response.Write "支持"
End If
其他组件同样处理,非常简单了。
最好在global文件中处理,里面使用的时候不用那么麻烦了。
最好的方法把邮件生成放到一个表里,然后再说发送的事情。
刘全洪 2009年圣诞
Function object_install(strClassString)
On Error Resume Next
object_install=False
Dim xTestObj
Err=0
Set xTestObj=Server.CreateObject(strClassString)
If Err=0 Then object_install=True
Set xTestObj=Nothing
Err=0
End Function
......
采集开始
第一步是分析要采集的页面。
使用浏览器打开要采集的页面(如:http://sports.sina.com.cn/k/2008-09-15/04593948756.shtml,你可以其他页面),打开后,点击右键,查源文件。
第二步,找到要采集的内容所在位置。
假如我要采集这个页面上的标题和内容所在的位置:
标题在<h1 id="artibodyTitle" style="color03005C;">和</h1>之间
内容在<!-- 正文内容 begin -->和<!-- 正文内容 end -->之间
注意一下所在位置的唯一性,可以在找到后,使用编辑中的查找,看看是不是唯一的,尽可能是唯一的,如果不是,尽可能是第一个,如果再不行,只能更换
第三步,写代码
复制代码 代码如下/div>
< %
'功能:asp采集代码
'作者:wangsdong
'备注:支持原创程序,请保留此信息,谢谢
url="http://sports.sina.com.cn/k/2008-09-15/04593948756.shtml"
str=getHTTPPage(url)
title=strcut(str,"<h1 id=""artibodyTitle"" style=""color03005C;"">","</h1>",2)
content=strcut(str,"<!-- 正文内容 begin -->","<!-- 正文内容 end -->",2)
response.write "新闻标题<br><b>"&t ......