?? maintest.c
字號:
#include <windows.h>
#include "resource.h"
#include "COM_Intercommunion.h"
LRESULT CALLBACK KeypadProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
if(OpenCOM( "COM1" , 9600, 8, None, Onestopbit)==0)
return 0;
if(InitModemDrive("COM1", "+8613010888500")==0)
return 0;
DialogBox(hInstance, (LPCTSTR)IDD_DIALOG1, NULL, (DLGPROC)KeypadProc);
return 0;
}
LRESULT CALLBACK KeypadProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
char stringmsg[256],strmsgtonum[32],strcallnum[32],strmsgrtn[64],strcallrtn[64],stringmsgcon[256];
HWND hwndmsg, hwndcall, hwndmsgtonum, hwndmsgrtn, hwndcallrtn, hwndmsgcon;
hwndmsg = GetDlgItem(hDlg, IDC_BUTTON1);
hwndcall = GetDlgItem(hDlg, IDC_EDIT2);
hwndmsgtonum = GetDlgItem(hDlg, IDC_EDIT3);
hwndmsgrtn = GetDlgItem(hDlg, IDC_EDIT4);
hwndcallrtn = GetDlgItem(hDlg, IDC_EDIT5);
hwndmsgcon = GetDlgItem(hDlg, IDC_EDIT1);
memset(stringmsg, 0, sizeof(stringmsg));
memset(strmsgtonum, 0, sizeof(strmsgtonum));
memset(strcallnum, 0, sizeof(strcallnum));
memset(strmsgrtn, 0, sizeof(strmsgrtn));
memset(strcallrtn, 0, sizeof(strcallrtn));
memset(stringmsgcon, 0, sizeof(stringmsgcon));
switch(message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_BUTTON1:
GetWindowText(hwndmsgcon, stringmsg, sizeof(stringmsg));
GetWindowText(hwndmsgtonum, strmsgtonum, sizeof(strmsgtonum));
switch(SendShortMsg("13800755500", strmsgtonum , stringmsg))
{
case SND_OK:
SetWindowText(hwndmsgrtn,"" );
sprintf(strmsgrtn, "The msg sent successful!\n\n");
SetWindowText(hwndmsgrtn,strmsgrtn );
break;
case SND_ERROR:
SetWindowText(hwndmsgrtn,"" );
sprintf(strmsgrtn, "The msg sent fail!\n\n");
SetWindowText(hwndmsgrtn,strmsgrtn );
break;
case SND_UNKNOW_ERROR:
SetWindowText(hwndmsgrtn,"" );
sprintf(strmsgrtn, "The msg sent fail.encounter unkonw error!\n\n");
SetWindowText(hwndmsgrtn,strmsgrtn );
break;
}
break;
case IDC_BUTTON2:
GetWindowText(hwndcall, strcallnum, sizeof(strcallnum));
switch(MakeDial(strcallnum))
{
case MAKE_DIAL_OK:
SetWindowText(hwndcallrtn,"" );
sprintf(strcallrtn, "The call successful!\n\n");
SetWindowText(hwndcallrtn,strcallrtn );
break;
case MAKE_DIAL_CONNECT:
SetWindowText(hwndcallrtn,"" );
sprintf(strcallrtn, "The call successful!\n\n");
SetWindowText(hwndcallrtn,strcallrtn );
break;
case MAKE_DIAL_BUSY:
SetWindowText(hwndcallrtn,"" );
sprintf(strcallrtn, "the called party in communication!\n\n");
SetWindowText(hwndcallrtn,strcallrtn );
break;
case MAKE_DIAL_NO_ANSWER:
SetWindowText(hwndcallrtn,"" );
sprintf(strcallrtn, "no hang up is deteced after a fixed network timeout!\n\n");
SetWindowText(hwndcallrtn,strcallrtn );
break;
case MAKE_DIAL_NO_CARRIER:
SetWindowText(hwndcallrtn,"" );
sprintf(strcallrtn, "call setup failed or remote user release!\n\n");
SetWindowText(hwndcallrtn,strcallrtn );
break;
case MAKE_DIAL_NO_UNKNOW_ERROR:
SetWindowText(hwndcallrtn,"" );
sprintf(strcallrtn, "The call fial. encounter unknow error!\n\n");
SetWindowText(hwndcallrtn,strcallrtn );
}
break;
case IDCANCEL:
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
}
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -