15,473
社区成员




void CTestDlg::OnConnectionButton()
{
UpdateData();
CString strText;
CString strtmp;
CString tmp[256];
strtmp="//上海迅赛信息技术有限公司,网址www.xunsai.com//";
typedef int(_stdcall *Sms_Connection)(CString CopyRight,int Com_Port,int Com_BaudRate,CString *Mobile_Type);
Sms_Connection Proc;
Proc = (Sms_Connection)GetProcAddress(hinstDLL,"Sms_Connection");
//********监视Proc地址:0x0103BF1C
CString aa="";
aa.Format(_T("%x"),Proc);
AfxMessageBox(aa);
int iValue = Proc(strtmp,5,19200,tmp);
//********Win32调用成功,即iValue=1
if (iValue == 1)
{
strText.Format("短信猫连接成功!(短信猫型号为:%s)",*tmp);
AfxMessageBox(strText);
} else if (iValue == 0) {
AfxMessageBox("短信猫连接失败!(请重新连接短信猫)");
}
}
JNIEXPORT jstring JNICALL Java_com_rhinofield_common_GsmModemInterface_Sms_1Connection
(JNIEnv *env, jclass cls, jstring copyRight, jint com_Port, jint com_BaudRate)
{
CString cp="//上海迅赛信息技术有限公司,网址www.xunsai.com//";
char *buffer2=NULL;
hinstDLL=LoadLibrary(_T("sms.dll"));
typedef int(_stdcall *Sms_Connection)(CString CopyRight,int Com_Port,int Com_BaudRate,CString *Mobile_Type);
Sms_Connection Proc=(Sms_Connection)GetProcAddress(hinstDLL,"Sms_Connection");
//*******监视Proc地址:0x0726BF1C
if(Proc==NULL)
{
DWORD abc=GetLastError();
cp.Format(_T("error code:%ld"),abc);
buffer2=CStringToChar(cp);
}
else
{
CString mobile_Type[256];
int rtnValue = Proc(cp,5,19200,mobile_Type);
//*******DLL调用失败,即rtnValue=0
if(rtnValue==0)
{
cp.Format(_T("com_Port=%d,com_BaudRate=%d,mobile_Type=%s"),com_Port,com_BaudRate,*mobile_Type);
cp="3:rtnValue=0||"+cp;
buffer2=CStringToChar(cp);
}
else
{
cp.Format(_T("%s"),*mobile_Type);
cp="4:GSM Modem Success!Type="+cp;
buffer2=CStringToChar(cp);
}
}
FreeLibrary(hinstDLL);
jstring result = env->NewStringUTF(buffer2);
free(buffer2);
return result;
}