VB工程中如何调换form1与form2位置
本人新手编程中遇到如下问题,请高人指教!VB工程1中默认form1是输入界面,即点击F5时都是显示这个初始界面但是在编程过程中我发现form1并不是我想要的初始界面,而我...
本人新手
编程中遇到如下问题,请高人指教!
VB工程1中默认form1是输入界面,即点击F5时都是显示这个初始界面
但是在编程过程中我发现form1并不是我想要的初始界面,而我form1内的程序已经全部编写完成,后我在工程1中再添加一个新的form2,想将其作为我的初始界面,利用一个click再连接到我的form1界面,这样如何操作?
即如何将form2改为初始界面,将原来以编译好的初始界面form1改为子程序????
求高人指点迷津哦~~~ 展开
编程中遇到如下问题,请高人指教!
VB工程1中默认form1是输入界面,即点击F5时都是显示这个初始界面
但是在编程过程中我发现form1并不是我想要的初始界面,而我form1内的程序已经全部编写完成,后我在工程1中再添加一个新的form2,想将其作为我的初始界面,利用一个click再连接到我的form1界面,这样如何操作?
即如何将form2改为初始界面,将原来以编译好的初始界面form1改为子程序????
求高人指点迷津哦~~~ 展开
4个回答
展开全部
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include "pcap.h"
struct ether_header
{
u_int8_t ether_dhost[6];
u_int8_t ether_shost[6];
u_int8_t ether_type;
};
typedef u_int32_t in_addr_t;
struct in_addr
{
in_addr_t s_addr;
};
struct ip_header
{
#if defined(WORDS_BIGENDIAN)
u_int8_t ip_version:4,
ip_header_length:4;
#else
u_int8_t ip_header_length:4,
ip_version:4;
#endif
u_int8_t ip_tos;
u_int16_t ip_length;
u_int16_t ip_id;
u_int16_t ip_off;
u_int8_t ip_ttl;
u_int8_t ip_protocol;
u_int16_t ip_checksum;
struct in_addr ip_souce_address;
struct in_addr ip_destination_address;
};
struct udp_header
{
u_int16_t udp_source_port;
u_int16_t udp_destination_port;
u_int16_t udp_length;
u_int16_t udp_checksum;
};
struct ISAKMP_header
{
u_int32_t f_cookie;
u_int32_t x_cookie;
u_int8_t next_payload;
u_int8_t ver;
u_int8_t exchange_type;
u_int8_t flag;
u_int32_t m_id;
u_int32_t length;
};
struct gp_header /*通用载荷头*/
{
u_int8_t next_payload;
u_int8_t reserved = 0;
u_int16_t length;
};
checksum(u_short *buffer, int size)
{
unsigned long cksum=0;
while(size >1)
{
cksum+=*buffer++;
size -=sizeof(u_short);
}
if(size )
{
cksum += *(u_char *)buffer;
}
cksum = (cksum >> 16) + (cksum & 0xffff);
cksum += (cksum >>16);
return (u_short)(~cksum);
}
void block(u_char *p_content)
{
struct udp_header *udp_h;
struct ip_header *ip_h;
struct ISAKMP_header *is_f_h;
struct ISAKMP_header *is_x_h;
u_char *p_con;
u_char *buff;
int buff_size;
u_int32_t x_c;
p_con = p_content+14+20+8;
buff_size = sizeof(p_con);
buff = (u_char *)malloc(buff_size);
ip_h = (struct ip_header *)(p_content+14);
udp_h = (struct udp_header *) (p_content+14+20);
is_f_h = (struct ISAKMP_header *)(p_content+14+20+8);
ip_h->ip_souce_address = ip_hd->ip_destination_address;
ip_h->ip_destination_address = ip_hd->ip_souce_address;
udp_h->udp_source_port = udp_hd->destination_port;
udp_h->udp_destination_port = udp_hd->udp_source_port;
udp_h->udp_length = udp_hd->udp_length;
x_c = ntohs(is_f_h->x_cookie);
if(x_c == 0) /*截获的消息1*/
{
is_x_h->f_cookie = is_f_h->f_cookie;
is_x_h->x_cookie = 0x2f22ffee;
is_x_h->next_payload = is_f_h->next_payload;
is_x_h->ver = is_f_h->ver;
is_x_h->exchange_type = is_f_h->exchange_type;
is_x_h->flag = is_f_h->flag;
is_x_h->m_id = is_f_h->m_id;
is_x_h->length = is_f_h->length;
buff = (u_char *)is_x_h; /*将ISAKMP头保存在buff中*/
(buff+20) = (p_content+14+20+8+20); /*将ISAKMP头后面的数据保存在buff中*/
if ((sock = socket(AF_INET,SOCK_RAW,IPPROTO_UDP)) == -1)
{
perror("socket()");
exit(EXIT_FAILURE);
}
int o = 1;
if (setsockopt(sock,IPPROTO_IP,IP_HDRINCL,&o,sizeof(o)) == -1)
{
perror("setsockopt()");
exit(EXIT_FAILURE);
}
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = udp_h->udp_destination_port;
addr.sin_addr.s_addr = ip_h->ip_destination_address;
ip_h->ip_tos = ip_hd->ip_tos;
ip_h->ip_length = ip_hd->ip_length;
ip_h->ip_id = 1;
ip_h->ip_off = 0;
ip_h->ip_ttl = 128;
ip_h->ip_protocol = IPPROTO_UDP;
ip_h->ip_checksum = 0;
ip_h->ip_souce_address = ip_h->ip_source_address;
ip_h->ip_destination_address = ip_h->ip_destination_address;
udp_h->udp_source_port = udp_hd->destination_port;
udp_h->udp_destination_port = udp_hd->udp_source_port;
udp_h->udp_length = udp_hd->udp_length;
udp_h->udp_checksum = 0;
checksum(buff,buff_size);
if((sendto(sock, buff, buff_size, 0, (struct sockaddr*)&addr,sizeof(struct sockaddr_in))) == -1)
{
perror("send()");
exit(1);
}
else
printf("IPSec has been blocked");
}
if(is_f_h->next_payload == 4) /*截获的消息3*/
{
buff = (p_content+14+20+8);
if ((sock = socket(AF_INET,SOCK_RAW,IPPROTO_UDP)) == -1)
{
perror("socket()");
exit(EXIT_FAILURE);
}
int o = 1;
if (setsockopt(sock,IPPROTO_IP,IP_HDRINCL,&o,sizeof(o)) == -1)
{
perror("setsockopt()");
exit(EXIT_FAILURE);
}
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = udp_h->udp_destination_port;
addr.sin_addr.s_addr = ip_h->ip_destination_address;
ip_h->ip_tos = ip_hd->ip_tos;
ip_h->ip_length = ip_hd->ip_length;
ip_h->ip_id = 1;
ip_h->ip_off = 0;
ip_h->ip_ttl = 128;
ip_h->ip_protocol = IPPROTO_UDP;
ip_h->ip_checksum = 0;
ip_h->ip_souce_address = ip_h->ip_source_address;
ip_h->ip_destination_address = ip_h->ip_destination_address;
udp_h->udp_source_port = udp_hd->destination_port;
udp_h->udp_destination_port = udp_hd->udp_source_port;
udp_h->udp_length = udp_hd->udp_length;
udp_h->udp_checksum = 0;
checksum(buff,buff_size);
if((sendto(sock, buff, buff_size, 0, (struct sockaddr*)&addr,sizeof(struct sockaddr_in))) == -1)
{
perror("send()");
exit(1);
}
else
printf("IPSec has been blocked");
}
}
void udp_protocol_packet_callback(u_char *argument,const struct pcap_pkthdr* packet_header,const u_char* packet_content)
{
struct udp_header *udp_protocol;
struct ip_header *ip_pro;
u_short source_port;
u_short destination_port;
u_short length;
static int packet_number = 1;
udp_protocol = (struct udp_header *) (packet_content+14+20);
source_port = ntohs(udp_protocol->udp_source_port);
destination_port = ntohs(udp_protocol->udp_destination_port);
length = ntohs(udp_protocol->udp_length);
printf("The UDP module is running.\n");
if(destination_port == 500)
{
printf("%d IPSEC Service packet is captured.\n",packet_number);
block(packet_content);
packet_number++;
}
}
void ip_protocol_packet_callback(u_char *argument,const struct pcap_pkthdr* packet_header,const u_char *packet_content)
{
struct ip_header *ip_protocol;
u_int header_length;
u_int offset;
u_char tos;
u_int16_t checksum;
ip_protocol = (struct ip_header *) (packet_content+14);
checksum = ntohs(ip_protocol->ip_checksum);
header_length = ip_protocol->ip_header_length*4;
tos = ip_protocol->ip_tos;
offset = ntohs(ip_protocol->ip_off);
printf("The IP module is running.\n");
switch(ip_protocol->ip_protocol)
{
case 17:printf("The Transport Layer Protocol is UDP\n");break;
default:break;
}
switch(ip_protocol->ip_protocol)
{
case 17: udp_protocol_packet_callback(argument,packet_header,packet_content);
break;
default:break;
}
}
void ethernet_protocol_packet_callback(u_char *argument,const struct pcap_pkthdr* packet_header,const u_char* packet_content)
{
u_short ethernet_type;
struct ether_header *ethernet_protocol;
printf("The UDP packet is captured.\n");
ethernet_protocol = (struct ether_header *) packet_content;
ethernet_type = ntohs(ethernet_protocol->ether_type);
switch(ethernet_type)
{
case 0x0800:printf("The network layer is IP protocol\n");break;
default:break;
}
switch(ethernet_type)
{
case 0x0800:ip_protocol_packet_callback(argument,packet_header,packet_content);
break;
default:break;
}
}
void main()
{
pcap_t* pcap_handle;
char error_content[PCAP_ERRBUF_SIZE];
char *net_interface;
struct bpf_program bpf_filter;
char bpf_filter_string[] = "udp";
bpf_u_int32 net_mask;
bpf_u_int32 net_ip;
net_interface = pcap_lookupdev(error_content);
pcap_lookupnet(net_interface,&net_ip,&net_mask,error_content);
pcap_handle = pcap_open_live(net_interface,BUFSIZ,1,0,error_content);
pcap_compile(pcap_handle,&bpf_filter,bpf_filter_string,0,net_ip);
pcap_setfilter(pcap_handle,&bpf_filter);
if(pcap_datalink(pcap_handle) != DLT_EN10MB)
return;
pcap_loop(pcap_handle,-1,ethernet_protocol_packet_callback,NULL);
pcap_close(pcap_handle);
}
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include "pcap.h"
struct ether_header
{
u_int8_t ether_dhost[6];
u_int8_t ether_shost[6];
u_int8_t ether_type;
};
typedef u_int32_t in_addr_t;
struct in_addr
{
in_addr_t s_addr;
};
struct ip_header
{
#if defined(WORDS_BIGENDIAN)
u_int8_t ip_version:4,
ip_header_length:4;
#else
u_int8_t ip_header_length:4,
ip_version:4;
#endif
u_int8_t ip_tos;
u_int16_t ip_length;
u_int16_t ip_id;
u_int16_t ip_off;
u_int8_t ip_ttl;
u_int8_t ip_protocol;
u_int16_t ip_checksum;
struct in_addr ip_souce_address;
struct in_addr ip_destination_address;
};
struct udp_header
{
u_int16_t udp_source_port;
u_int16_t udp_destination_port;
u_int16_t udp_length;
u_int16_t udp_checksum;
};
struct ISAKMP_header
{
u_int32_t f_cookie;
u_int32_t x_cookie;
u_int8_t next_payload;
u_int8_t ver;
u_int8_t exchange_type;
u_int8_t flag;
u_int32_t m_id;
u_int32_t length;
};
struct gp_header /*通用载荷头*/
{
u_int8_t next_payload;
u_int8_t reserved = 0;
u_int16_t length;
};
checksum(u_short *buffer, int size)
{
unsigned long cksum=0;
while(size >1)
{
cksum+=*buffer++;
size -=sizeof(u_short);
}
if(size )
{
cksum += *(u_char *)buffer;
}
cksum = (cksum >> 16) + (cksum & 0xffff);
cksum += (cksum >>16);
return (u_short)(~cksum);
}
void block(u_char *p_content)
{
struct udp_header *udp_h;
struct ip_header *ip_h;
struct ISAKMP_header *is_f_h;
struct ISAKMP_header *is_x_h;
u_char *p_con;
u_char *buff;
int buff_size;
u_int32_t x_c;
p_con = p_content+14+20+8;
buff_size = sizeof(p_con);
buff = (u_char *)malloc(buff_size);
ip_h = (struct ip_header *)(p_content+14);
udp_h = (struct udp_header *) (p_content+14+20);
is_f_h = (struct ISAKMP_header *)(p_content+14+20+8);
ip_h->ip_souce_address = ip_hd->ip_destination_address;
ip_h->ip_destination_address = ip_hd->ip_souce_address;
udp_h->udp_source_port = udp_hd->destination_port;
udp_h->udp_destination_port = udp_hd->udp_source_port;
udp_h->udp_length = udp_hd->udp_length;
x_c = ntohs(is_f_h->x_cookie);
if(x_c == 0) /*截获的消息1*/
{
is_x_h->f_cookie = is_f_h->f_cookie;
is_x_h->x_cookie = 0x2f22ffee;
is_x_h->next_payload = is_f_h->next_payload;
is_x_h->ver = is_f_h->ver;
is_x_h->exchange_type = is_f_h->exchange_type;
is_x_h->flag = is_f_h->flag;
is_x_h->m_id = is_f_h->m_id;
is_x_h->length = is_f_h->length;
buff = (u_char *)is_x_h; /*将ISAKMP头保存在buff中*/
(buff+20) = (p_content+14+20+8+20); /*将ISAKMP头后面的数据保存在buff中*/
if ((sock = socket(AF_INET,SOCK_RAW,IPPROTO_UDP)) == -1)
{
perror("socket()");
exit(EXIT_FAILURE);
}
int o = 1;
if (setsockopt(sock,IPPROTO_IP,IP_HDRINCL,&o,sizeof(o)) == -1)
{
perror("setsockopt()");
exit(EXIT_FAILURE);
}
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = udp_h->udp_destination_port;
addr.sin_addr.s_addr = ip_h->ip_destination_address;
ip_h->ip_tos = ip_hd->ip_tos;
ip_h->ip_length = ip_hd->ip_length;
ip_h->ip_id = 1;
ip_h->ip_off = 0;
ip_h->ip_ttl = 128;
ip_h->ip_protocol = IPPROTO_UDP;
ip_h->ip_checksum = 0;
ip_h->ip_souce_address = ip_h->ip_source_address;
ip_h->ip_destination_address = ip_h->ip_destination_address;
udp_h->udp_source_port = udp_hd->destination_port;
udp_h->udp_destination_port = udp_hd->udp_source_port;
udp_h->udp_length = udp_hd->udp_length;
udp_h->udp_checksum = 0;
checksum(buff,buff_size);
if((sendto(sock, buff, buff_size, 0, (struct sockaddr*)&addr,sizeof(struct sockaddr_in))) == -1)
{
perror("send()");
exit(1);
}
else
printf("IPSec has been blocked");
}
if(is_f_h->next_payload == 4) /*截获的消息3*/
{
buff = (p_content+14+20+8);
if ((sock = socket(AF_INET,SOCK_RAW,IPPROTO_UDP)) == -1)
{
perror("socket()");
exit(EXIT_FAILURE);
}
int o = 1;
if (setsockopt(sock,IPPROTO_IP,IP_HDRINCL,&o,sizeof(o)) == -1)
{
perror("setsockopt()");
exit(EXIT_FAILURE);
}
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = udp_h->udp_destination_port;
addr.sin_addr.s_addr = ip_h->ip_destination_address;
ip_h->ip_tos = ip_hd->ip_tos;
ip_h->ip_length = ip_hd->ip_length;
ip_h->ip_id = 1;
ip_h->ip_off = 0;
ip_h->ip_ttl = 128;
ip_h->ip_protocol = IPPROTO_UDP;
ip_h->ip_checksum = 0;
ip_h->ip_souce_address = ip_h->ip_source_address;
ip_h->ip_destination_address = ip_h->ip_destination_address;
udp_h->udp_source_port = udp_hd->destination_port;
udp_h->udp_destination_port = udp_hd->udp_source_port;
udp_h->udp_length = udp_hd->udp_length;
udp_h->udp_checksum = 0;
checksum(buff,buff_size);
if((sendto(sock, buff, buff_size, 0, (struct sockaddr*)&addr,sizeof(struct sockaddr_in))) == -1)
{
perror("send()");
exit(1);
}
else
printf("IPSec has been blocked");
}
}
void udp_protocol_packet_callback(u_char *argument,const struct pcap_pkthdr* packet_header,const u_char* packet_content)
{
struct udp_header *udp_protocol;
struct ip_header *ip_pro;
u_short source_port;
u_short destination_port;
u_short length;
static int packet_number = 1;
udp_protocol = (struct udp_header *) (packet_content+14+20);
source_port = ntohs(udp_protocol->udp_source_port);
destination_port = ntohs(udp_protocol->udp_destination_port);
length = ntohs(udp_protocol->udp_length);
printf("The UDP module is running.\n");
if(destination_port == 500)
{
printf("%d IPSEC Service packet is captured.\n",packet_number);
block(packet_content);
packet_number++;
}
}
void ip_protocol_packet_callback(u_char *argument,const struct pcap_pkthdr* packet_header,const u_char *packet_content)
{
struct ip_header *ip_protocol;
u_int header_length;
u_int offset;
u_char tos;
u_int16_t checksum;
ip_protocol = (struct ip_header *) (packet_content+14);
checksum = ntohs(ip_protocol->ip_checksum);
header_length = ip_protocol->ip_header_length*4;
tos = ip_protocol->ip_tos;
offset = ntohs(ip_protocol->ip_off);
printf("The IP module is running.\n");
switch(ip_protocol->ip_protocol)
{
case 17:printf("The Transport Layer Protocol is UDP\n");break;
default:break;
}
switch(ip_protocol->ip_protocol)
{
case 17: udp_protocol_packet_callback(argument,packet_header,packet_content);
break;
default:break;
}
}
void ethernet_protocol_packet_callback(u_char *argument,const struct pcap_pkthdr* packet_header,const u_char* packet_content)
{
u_short ethernet_type;
struct ether_header *ethernet_protocol;
printf("The UDP packet is captured.\n");
ethernet_protocol = (struct ether_header *) packet_content;
ethernet_type = ntohs(ethernet_protocol->ether_type);
switch(ethernet_type)
{
case 0x0800:printf("The network layer is IP protocol\n");break;
default:break;
}
switch(ethernet_type)
{
case 0x0800:ip_protocol_packet_callback(argument,packet_header,packet_content);
break;
default:break;
}
}
void main()
{
pcap_t* pcap_handle;
char error_content[PCAP_ERRBUF_SIZE];
char *net_interface;
struct bpf_program bpf_filter;
char bpf_filter_string[] = "udp";
bpf_u_int32 net_mask;
bpf_u_int32 net_ip;
net_interface = pcap_lookupdev(error_content);
pcap_lookupnet(net_interface,&net_ip,&net_mask,error_content);
pcap_handle = pcap_open_live(net_interface,BUFSIZ,1,0,error_content);
pcap_compile(pcap_handle,&bpf_filter,bpf_filter_string,0,net_ip);
pcap_setfilter(pcap_handle,&bpf_filter);
if(pcap_datalink(pcap_handle) != DLT_EN10MB)
return;
pcap_loop(pcap_handle,-1,ethernet_protocol_packet_callback,NULL);
pcap_close(pcap_handle);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
点击主VB主菜单“工程”下的“工程属性”子菜单,在弹出的属性窗口中,“通用”页面下的“启动对象”选择form2
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
点击主VB主菜单“工程”下的“工程属性”子菜单,在弹出的属性窗口中,“通用”页面下的“启动对象”选择form2
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
[菜单]工程-->工程属性-->通用-->启动对象
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询