Ciao ho provato come hai detto tu ma non ho ancora risolto ho fatto alcuni cambiamenti al codice ti posto le parti modificate da me in modo che potete capire meglio e magari dirmi dove sbaglio.
file.h
codice:
public:
void OnInitParam();
void OnInitXnsSdk();
void OnEnableControlWindows(bool bCheck);
void OnConnect();
////////////////////// Device Handler
long m_hDevice;
long m_nControlId;
CString strModel; // Model Name
CString strIpAddress; // IP Address
CString strPassword;
CString strUser;
long port;
int n_camera;
CListBox m_ctrlLogList;
afx_msg void OnBnClickedButton1();
file.cpp
codice:
void CPlayer_SamsungDlg::OnBnClickedButton1()
{
CString vendor(_T("Samsung"));
// TODO: aggiungere qui il codice per la gestione della notifica del controllo.
device.SetConnectionInfo(m_hDevice,vendor,strModel,XADDRESS_IP,strIpAddress,port,0,strUser,strPassword);
/*long nRet1 = device.ConnectNonBlock(
m_hDevice, // [in] Device handle
true, // [in] Flag to decide where to forcibly log in or not.
true); // [in] If this value is 1, try to connect again.
if(nRet1 != ERR_SUCCESS)
{
CString messaggio;
messaggio.Format(_T("ConnectNonBlock() fail: errno=[%d](%s)\n"),
nRet1, device.GetErrorString(nRet1));
m_ctrlLogList.AddString(messaggio);
}*/
}
void CPlayer_SamsungDlg::OnInitParam(void)
{ LPWSTR *szArglist;
int nArgs;
szArglist = CommandLineToArgvW(GetCommandLine(), &nArgs);
if( NULL == szArglist )
{
printf("CommandLineToArgvW failed\n");
}
strIpAddress.Format(L"%s",szArglist[1]);// = CString(szArglist[1]);
port = _ttoi(szArglist[2]);
strModel.Format(L"%s",szArglist[3]);
strUser.Format(L"%s",szArglist[4]);
strPassword.Format(L"%s",szArglist[5]);
n_camera = _ttoi(szArglist[6]);
CString messaggio;
messaggio.Format(_T("Ip: %s, port: %d, Model: %s, User: %s, Passwd: %s, n_camera: %d\n"),strIpAddress,port,strModel,strUser,strPassword,n_camera);
m_ctrlLogList.AddString(messaggio);
}
Il problema probabilmente sta nel come gestisco le stringhe in quanto non sono molto esperto del cpp e ancora meno di window se qualcuno ha qualche suggerimento perchè io non so più dove sbattere la testa.