在书上看到了一个新邮件检查器的例子,按着打了出来可是一直出现一个缺少存储类或类型说明符的错误!网上找了相关文章代码也和我的一模一样,实在是无法发现程序错在哪里,不知道哪位大虾能指点一下小弟,不胜感激!
下面给出所有源代码。只要先建一个C++的控制台应用程序(.net),直接把代码全部放进源文件就可以了。
不知道哪里错,急,希望各位高手帮忙发现问题!谢谢了!
#include "stdafx.h"
#using <mscorlib.dll>
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Net::Sockets;
using namespace System::IO;
using namespace System::Data;
using namespace System::Text;
using namespace System::Collections;
using namespace System::ComponentModel;
public __gc class MainForm : public Form
{
private:
Label *label1; //三个标签
Label *label2;
Label *label3;
TextBox *ServerAdd; //输入框,表示服务器地址
TextBox *Username; //输入框,表示用户名
TextBox *Password; //输入框,表示用户密码
Button *btnChecker; //按钮
CPOP3Client *pPOP3Client;
void btn_Click( Object *sender, System::EventArgs *e );
int MailChecker();
public:
MainForm();
};
MainForm::MainForm()
{
StartPosition = FormStartPosition::CenterScreen; //开始运行时显示于屏幕中央
Text = "新邮件检查器";
Size = Drawing::Size( 300, 200 );
MaximizeBox = false; //让最大化按钮失效
FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
label1 = new Label();
label1->Location = Drawing::Point( 20, 16 );
label1->Name = "label1";
label1->Size = Drawing::Size( 104, 23 );
label1->Text = "邮件服务器地址:";
label1->TextAlign = Drawing::ContentAlignment::MiddleLeft;
Controls->Add( label1 );
label2 = new Label();
label2->Location = Drawing::Point( 20, 56 );
label2->Name = "label2";
label2->Size = Drawing::Size( 104, 23 );
label2->Text = "用户名:";
label2->TextAlign = Drawing::ContentAlignment::MiddleLeft;
Controls->Add( label2 );
label3 = new Label();
label3->Location = Drawing::Point( 20, 96 );
label3->Name = "label3";
label3->Size = Drawing::Size( 104, 23 );
label3->Text = "密码:";
label3->TextAlign = Drawing::ContentAlignment::MiddleLeft;
Controls->Add( label3 );
ServerAdd = new TextBox();
ServerAdd->Location = Drawing::Point( 130, 16 );
ServerAdd->Name = "ServerAdd";
ServerAdd->Size = Drawing::Size( 136, 21 );
ServerAdd->TabIndex = 0;
ServerAdd->Text = "";
Controls->Add( ServerAdd );
Username = new TextBox();
Username->Location = Drawing::Point( 130, 55 );
Username->Name = "Username";
Username->Size = Drawing::Size( 136, 21 );
Username->TabIndex = 1;
Username->Text = "";
Controls->Add( Username );
Password = new TextBox();
Password->Location = Drawing::Point( 130, 94 );
Password->Name = "Password";
Password->PasswordChar = '*';
Password->Size = Drawing::Size( 136, 21 );
Password->TabIndex = 2;
Password->Text = "";
Controls->Add( Password );
btnChecker = new Button();
btnChecker->Location = Drawing::Point( 177, 130 );
btnChecker->Name = "btnChecker";
btnChecker->Size = Drawing::Size( 90, 25 );
btnChecker->TabIndex = 3;
btnChecker->Text = "开始检查邮箱";
btnChecker->add_Click( new EventHandler( this, &MainForm::btn_Click) );
Controls->Add( btnChecker );
}