一个程式异常,有哪位高手可以帮帮小弟我?
一个程式错误,有谁可以帮帮我??
我有一个程式是关于当插入移动硬盘时,输入密码把移动硬盘锁住
我先调出.dll
(FARPROC&)SecuritySetPassword = ::GetProcAddress(m_hDLL,"SecuritySetPassword");
在header file 加入要用的函数
跟着调入函数,具体代码如下
void CLoginDlg::OnOK()
{
// TODO: Add extra validation here
size_t passwdcnt;
char buffer1[64];
char buffer2[64];
memset(buffer1,0,64);
memset(buffer2,0,64);
CEdit*pass1=(CEdit*)this->GetDlgItem(IDC_EDIT_SET_PASS1);
pass1->GetLine(0,buffer1,64);
CEdit*pass2=(CEdit*)this->GetDlgItem(IDC_EDIT_SET_PASS2);
pass2->GetLine(0,buffer2,64);
passwdcnt=strlen(buffer1);
if (passwdcnt>20)
{
::MessageBox(NULL,"Password cannot be longer than 20 characters","Warning",MB_OK|MB_ICONINFORMATION);
pass1->SetWindowText("");
pass1->SetFocus();
}
else if (passwdcnt==0)
{
::MessageBox(NULL,"Password Enter Password!","Warning",MB_OK|MB_ICONINFORMATION);
pass2->SetWindowText("");
pass1->SetFocus();
}
else if (strcmp(buffer1,buffer2)!=0)
{
::MessageBox(NULL,"Password MisMatch","Set Password Error",MB_OK|MB_ICONERROR);
pass1->SetWindowText("");
pass2->SetWindowText("");
pass1->SetFocus();
}
else
if(SecuritySetPassword((unsign char *)buffer1) == FALSE )
{
::MessageBox(NULL,"Set User Password Error","Error",MB_OK|MB_ICONERROR);
OnOK();
return ;
}
}
但当我输入密码时会出现一个error box说 Login MFC Application has encountered a problem and needs to close. We are sorry for the inconvenience.
到底是那里有问题啊,经过测试,好像是if(SecuritySetPassword((unsign char *)buffer1) == FALSE )这句导致出现错误,,有谁可以帮帮我???
------解决方案--------------------
你确认参数没有问题,buffer的长度足够么,如果确认,那估计就是dll里面的问题了吧
------解决方案--------------------
你好像没有对SecuritySetPassword 有效性进行检查,是不是GetProcAddress失败,返回NULL啊。
我有一个程式是关于当插入移动硬盘时,输入密码把移动硬盘锁住
我先调出.dll
(FARPROC&)SecuritySetPassword = ::GetProcAddress(m_hDLL,"SecuritySetPassword");
在header file 加入要用的函数
跟着调入函数,具体代码如下
void CLoginDlg::OnOK()
{
// TODO: Add extra validation here
size_t passwdcnt;
char buffer1[64];
char buffer2[64];
memset(buffer1,0,64);
memset(buffer2,0,64);
CEdit*pass1=(CEdit*)this->GetDlgItem(IDC_EDIT_SET_PASS1);
pass1->GetLine(0,buffer1,64);
CEdit*pass2=(CEdit*)this->GetDlgItem(IDC_EDIT_SET_PASS2);
pass2->GetLine(0,buffer2,64);
passwdcnt=strlen(buffer1);
if (passwdcnt>20)
{
::MessageBox(NULL,"Password cannot be longer than 20 characters","Warning",MB_OK|MB_ICONINFORMATION);
pass1->SetWindowText("");
pass1->SetFocus();
}
else if (passwdcnt==0)
{
::MessageBox(NULL,"Password Enter Password!","Warning",MB_OK|MB_ICONINFORMATION);
pass2->SetWindowText("");
pass1->SetFocus();
}
else if (strcmp(buffer1,buffer2)!=0)
{
::MessageBox(NULL,"Password MisMatch","Set Password Error",MB_OK|MB_ICONERROR);
pass1->SetWindowText("");
pass2->SetWindowText("");
pass1->SetFocus();
}
else
if(SecuritySetPassword((unsign char *)buffer1) == FALSE )
{
::MessageBox(NULL,"Set User Password Error","Error",MB_OK|MB_ICONERROR);
OnOK();
return ;
}
}
但当我输入密码时会出现一个error box说 Login MFC Application has encountered a problem and needs to close. We are sorry for the inconvenience.
到底是那里有问题啊,经过测试,好像是if(SecuritySetPassword((unsign char *)buffer1) == FALSE )这句导致出现错误,,有谁可以帮帮我???
------解决方案--------------------
你确认参数没有问题,buffer的长度足够么,如果确认,那估计就是dll里面的问题了吧
------解决方案--------------------
你好像没有对SecuritySetPassword 有效性进行检查,是不是GetProcAddress失败,返回NULL啊。