⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sms1.~cpp

📁 短信发送平台的源码
💻 ~CPP
📖 第 1 页 / 共 5 页
字号:
        fclose(fp);
        */
}
//---------------------------------------------------------------------------

void __fastcall TForm1::tongxunbo_buton(TObject *Sender)
{
TDateTime  DateTime ;
        AnsiString timeS ;

        AnsiString dateS  ;
        AnsiString shijianS;
        //ShowMessage("hhh");
       FILE *fp;
       char str[1024];
       //ShowMessage( "./cust/cust");
       if((fp = fopen("./cust/cust","r"))==NULL){  return ;}

        fgets(str,1024,fp);
        fgets(str,1024,fp);
        //ShowMessage( str);
        int i=0;
       TListItem *ListItem1;

          ListView7->Items->Clear();
        //ListItem1 = ListView6->Items->Add( )  ;
        //ListItem1->SubItems->Add("aaa");
        //ListItem1->SubItems->Add("bbb");
        //ListItem1->SubItems->Text="qqqqqqqqqqqqqqqqqqqqq";
        //ListItem1->SubItems->Text="xxxxxxxxxxxxxxxxxxxx";
        //ListItem1->Caption="qqqqqqqqqqqqqqqqqqqqq";
        //int i= ListItem1->Index+1;
       while (!feof(fp ))
        {          i++;
                   tongxun_acc=i;
                 memset(str,0x00,sizeof(str));
                 fgets(str,1024,fp);
                  AnsiString ssss;
                  ssss=str;
                 //ShowMessage( ssss);
                 if(strlen(str)<=1) continue;
                 char code[200] ;
                 AnsiString sss;
                 //ShowMessage( ssss);
                 getstring(str, 1,code,'=')  ;
                 sss=code;
                 //ShowMessage( ssss);
               ListItem1 = ListView7->Items->Add( )  ; ;
               ListItem1->Caption=sss;


        }
        fclose(fp);
          // Memo7->Text+code;
        //ListItem->Index=-1;
}
//---------------------------------------------------------------------------







void __fastcall TForm1::tongxunbo_change_listv7(TObject *Sender,
      TListItem *Item, TItemChange Change)
{
          FILE *fp;
        char str[1024] ;
        if((fp = fopen("./cust/cust","r"))==NULL){  return ;}

        fgets(str,1024,fp);
        fgets(str,1024,fp);
        int i=0;
          char code[20],neirong[1000];

         
        for(i=0;i<=Item->Index;i++)
        {
                   memset(str,0x00,sizeof(str));
                   fgets(str,1024,fp);
                   AnsiString ssss;
                  ssss=str;
                  //ShowMessage( shoujihao->Text);
                 if(strlen(str)<=1) continue;

                 getstring(str, 1,code,'=')  ;



        }
         memset(neirong,0x00,sizeof(neirong));
        // strcpy(neirong,shoujihao->Text.c_str());
          strcat(shoujihao_str,code);
          //ShowMessage( code);
          shoujihao->Text= shoujihao_str;
        fclose(fp);
}
//---------------------------------------------------------------------------


void __fastcall TForm1::ChaXun_BitBtn1Click(TObject *Sender)
{
   FILE *fp;
 CreateDir("./cust/");
         WritePrivateProfileString(
                "cust" ,
                "000000" ,
                "222222",
                "./cust/cust"
        );
         if(strlen(Edit5->Text.c_str())<=1) {Memo13->Text="无此客户";return;}
        char strtmp[512] ;
          AnsiString  str1;

          GetPrivateProfileString("cust",Edit5->Text.c_str(),"wwwwww",strtmp,512, "./cust/cust");
         str1=strtmp;
        //  ShowMessage( str1);
       // strcpy(str,Memo10->Text.c_str() );
        //strcat(str,"#" );
        //strcat(str,Memo13->Text.c_str() );
         if(strcmp(strtmp,"wwwwww")!=0)
         {
                char fpname[40];
                sprintf(fpname,"./cust/%s",Edit5->Text.c_str());
                if((fp = fopen(fpname,"r"))==NULL)  {Memo13->Text="无此客户";return;}
                char str1[1024];
                int i=0;
                memset(str1,0x00,sizeof(str1));
                str1[i]=fgetc(fp);
                          while (!feof(fp)) {
                                  i++;
                                 str1[i]=fgetc(fp);

                         }
                fclose(fp);
                //ShowMessage(strtmp);
                Edit6->Text=strtmp;
                Memo13->Text=str1;
            }else
            {
                Memo13->Text="无此客户!";
            }


}
//---------------------------------------------------------------------------

void __fastcall TForm1::ChaXun_DianBoBitBtn1Click(TObject *Sender)
{
    FILE *fp;
 CreateDir("./query/");
         WritePrivateProfileString(
                "query" ,
                "000000" ,
                "222222",
                "./query/query"
        );
         if(strlen(Edit7->Text.c_str())<=1) {Memo8->Text="无此信息";return;}
        char strtmp[1024] ;
          AnsiString  str1;

          GetPrivateProfileString("query",Edit7->Text.c_str(),"wwwwww",strtmp,1024, "./query/query");
         str1=strtmp;
        //  ShowMessage( str1);
       // strcpy(str,Memo10->Text.c_str() );
        //strcat(str,"#" );
        //strcat(str,Memo13->Text.c_str() );
         if(strcmp(strtmp,"wwwwww")!=0)
         {

                Memo8->Text=strtmp;

            }else
            {
                Memo8->Text="无此信息!";
            }


}
//---------------------------------------------------------------------------

 
//---------------------------------------------------------------------------

 
//---------------------------------------------------------------------------
 
//---------------------------------------------------------------------------

/*For a string such as 96,n,8,1 or any other older-form mode string that doesn't end with an x or a p: 
1.fInX, fOutX, fOutXDsrFlow, and fOutXCtsFlow are all set to FALSE

fDtrControl is set to DTR_CONTROL_ENABLE

fRtsControl is set to RTS_CONTROL_ENABLE 

2.For a string such as 96,n,8,1,x or any other older-form mode string that ends with an x:
fInX and fOutX are both set to TRUE 

fOutXDsrFlow and fOutXCtsFlow are both set to FALSE 

fDtrControl is set to DTR_CONTROL_ENABLE 

fRtsControl is set to RTS_CONTROL_ENABLE 

3.For a string such as 96,n,8,1,p or any other older-form mode string that ends with a p: 
fInX and fOutX are both set to FALSE 

fOutXDsrFlow and fOutXCtsFlow are both set to TRUE 

fDtrControl is set to DTR_CONTROL_HANDSHAKE 

fRtsControl is set to RTS_CONTROL_HANDSHAKE 

*/
void __fastcall TForm1::Button7Click(TObject *Sender)
{
COMMTIMEOUTS to;
        HANDLE hCom = CreateFile("COM1",
                                GENERIC_READ | GENERIC_WRITE,  // 允许读写        
                                0,                            // 此项必须为0
                                NULL,                         // no security attrs
                                OPEN_EXISTING,                //设置产生方式
                                0,            // 同步。 异步通信时用 (  FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED)       
                                NULL );


        if(hCom)
        {
                DCB dcb;
ZeroMemory(&dcb,sizeof(dcb));

dcb.DCBlength=sizeof(dcb);
dcb.BaudRate=19200;
dcb.ByteSize=8;
dcb.Parity=NOPARITY;
dcb.StopBits=ONESTOPBIT;


                  dcb.fDtrControl = DTR_CONTROL_ENABLE ;
                  dcb.fRtsControl = RTS_CONTROL_ENABLE ;
                   dcb.fInX= FALSE ;
                  dcb.fOutX= FALSE ;
                   dcb.fOutxDsrFlow= FALSE;
                   dcb.fOutxCtsFlow= FALSE;

                 //dcb.fBinary = true ;
                 //dcb.fParity = true ;


                if(SetCommState(hCom,&dcb))
                {
                        DWORD ByteCount;

                        char  msg[20]  ;
                          memset(&to,0,sizeof(to));
                           to.ReadTotalTimeoutMultiplier =5;
                           to.ReadTotalTimeoutConstant = 1000;
                           SetCommTimeouts(hCom,&to);

                          SetupComm(hCom,512,512);// 设置读写缓冲区
                          PurgeComm( hCom, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR| PURGE_RXCLEAR ); //清干净输入、输出缓冲区

                         char strmsg[500] ;
                        memset(strmsg,0x00,sizeof(strmsg));

                        strcpy(strmsg,"at+cmgl=3\r\n");
                         msg[0]=26;
                          //strcat(strmsg,msg);
                          Sleep(2000);
                        WriteFile( hCom,strmsg,strlen(strmsg),&ByteCount,NULL);
                        Sleep(3000);
                        ShowMessage(IntToStr(ByteCount));

                        ReadFile( hCom,strmsg,500,&ByteCount,NULL);
                        ShowMessage(strmsg);
                         ShowMessage(IntToStr(ByteCount));
                        CloseHandle(hCom);
                       
                 }
        }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button13Click(TObject *Sender)
{
int i=1500;
char str1[100],setCOM[10];
// ListView6->Items->Item->Caption ="aaaaaaaaaa"
String ss ;
        GetPrivateProfileString("SET","COM","222",setCOM,10, "./server.txt");
ShowMessage(setCOM);
}
//---------------------------------------------------------------------------


void __fastcall TForm1::SheZhi_enter(TObject *Sender)
{
char str[20];
memset(str,0,20);
GetPrivateProfileString("SET","COM","COM1",str,100, "./server.txt");
Edit1->Text=str;

GetPrivateProfileString("SET","RATE","19200",str,100, "./server.txt");
  Edit2->Text=str;
GetPrivateProfileString("SET","SMSCODE","88888888",str,100, "./server.txt");
 Edit3->Text=str;
}
//---------------------------------------------------------------------------


void __fastcall TForm1::Memo7DblClick(TObject *Sender)
{
//ShowMessage(Memo7->Lines->CommaText);
//   Memo7->
}
//---------------------------------------------------------------------------

void __fastcall TForm1::listView7change(TObject *Sender, TListItem *Item,
      TItemChange Change)
{     

     if( shoujihao->Text.Length()>1010) return ;
    if( Item->Selected==true)
                        shoujihao->Text=shoujihao->Text+Item->Caption+";";


}
//---------------------------------------------------------------------------

void __fastcall TForm1::Bbbb(TObject *Sender)
{

  //shoujihao->Text=Item->Caption+'\n';

}
//---------------------------------------------------------------------------


void __fastcall TForm1::ScrollBar1Change(TObject *Sender)
{
//shoujihao->le=-ScrollBar1->Position;
}
//---------------------------------------------------------------------------
 String  sms_EncodeChinese(String InputStr)
{
 		int cur;
String tempstr,returnstr;
WideString ws;
wchar_t  mid[2];
ws=WideString(InputStr);
for(int i=1;i<=ws.Length();i++)
{
wcscpy(mid,ws.SubString(i,1).c_bstr());
cur=mid[0];
FmtStr(tempstr,"%4.4X",ARRAYOFCONST((cur)));
returnstr=returnstr+tempstr;
}
return returnstr;
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
Label24->Caption="    初次使用时的步骤:\r\n\r\n1.用数据线把计算机和GSM modem(或手机)相连。                  \r\n";
Label24->Caption=Label24->Caption+"2. 设置 COM 串口。\r\n";
Label24->Caption=Label24->Caption+"3. 设置 波特率。\r\n";
Label24->Caption=Label24->Caption+"4. 设置 短信中心号码。\r\n";
Label24->Caption=Label24->Caption+"5. 点击 确定。\r\n";
Label24->Caption=Label24->Caption+"6. 点击 设备测试并保存参数。\r\n";
Label25->Caption= "7.等待弹出 ' 设备正常,设备参数保存正确,可以正常工作! '                                \r\n    的对话框 \r\n";
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
char setCOM[10],smsCO1[20];
 COMMTIMEOUTS to;
memset(setCOM,0,sizeof(setCOM));
memset(smsCO1,0,sizeof(smsCO1));
GetPrivateProfileString("SET","COM","COM1",setCOM,10, "./server.txt");
GetPrivateProfileString("SET","SMSCODE","0000000000",smsCO1,14, "./server.txt");
        HANDLE hCom = CreateFile(setCOM,
                                GENERIC_READ | GENERIC_WRITE,  // 允许读写        
                                0,                            // 此项必须为0
                                NULL,                         // no security attrs
                                OPEN_EXISTING,                //设置产生方式
                                0,            // 同步。 异步通信时用 (  FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED)       
                                NULL );



        if(hCom)
        {
                DCB dcb;
                char setRATE[10];
                memset(setRATE,0,10);
                GetPrivateProfileString("SET","RATE","19200",setRATE,10, "./server.txt");
                ZeroMemory(&dcb, sizeof(dcb));
                dcb.DCBlength = sizeof(dcb);
                dcb.BaudRate = atoi(setRATE);
                dcb.ByteSize = 8;
                dcb.Parity = NOPARITY;
                dcb.StopBits = ONESTOPBIT;
                dcb.fDtrControl = DTR_CONTROL_ENABLE ;
                dcb.fRtsControl = RTS_CONTROL_ENABLE ;
                dcb.fInX= FALSE ;
                dcb.fOutX= FALSE ;
                dcb.fOutxDsrFlow= FALSE;
                dcb.fOutxCtsFlow= FALSE;

                 
                if(SetCommState(hCom,&dcb))
             

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -