|
I remember something about using "COM1" as the path name for CreateFile when wanting to access the serial COM1 port.
I guess you just have to specify the name of the port then.
"It could have been worse, it could have been ME!"
|
|
|
|
|
Hi,
im trying to set the current working directory before going in to a file dialog and then reseting it to its original value after the dialog has closed:
TCHAR strCurrentDirectory[MAX_PATH];
GetCurrentDirectory(MAX_PATH, strCurrentDirectory);
CFileDialog fileDlg(TRUE, ".dot;.doc", NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR, "Microsoft Word Templates (*.dot; *.doc)|*.dot;*.doc|HTML Templates (*.htm; *.html)|*.htm; *.html|All files (*.*)|*.*||\0", NULL);
fileDlg.m_ofn.lpstrInitialDir = "c:\\projects\\temp";
if(fileDlg.DoModal() == IDOK)
{
// Do something
}
SetCurrentDirectory(strCurrentDirectory);
But this doesnt work as next time i go in to a different file dialog the current directory is set as c:\projects\temp.
Has anyone had to cope with a similar problem before and if so how did they get around it?
Cheers,
Andy.
|
|
|
|
|
Since you have used OFN_NOCHANGEDIR, you really don't need to use Get/SetCurrentDirectory at all.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Hi Probably you are using Windows 2000.
In this OS the last opened directories thru the
application is set in the registry and the
File Dialog reads thru that.
|
|
|
|
|
hi, yes i am using windows 2000. do you know where the registry entry is stored so that i can modify that myself.
Cheers,
Andy.
|
|
|
|
|
HKCU\Microsoft\Windows\Currentversion\explorer\comDlg32\OpenSaveMRU
Its got sub keys for well known extensions and generic keys for
those not registered, see if u can crack and let me know if u do.
|
|
|
|
|
I use a dialog based application with MFC.
The dialog also has a menu attached to it.
I use a view modal dialog boxes for settings and stuff.
Opening is not a problem but when I try to close this modal dialog the complete application closes. This happens when closing with either IDOK of IDCANCEL buttons.
The problem is that this only happens in Release mode. But without throwing an exeption of some kind.
When "debugging" the release version an exeption in msvcrt.dll at address 0x0000005 is thrown. But I have no clue why this happens.
In earlier versions of the program (without menu but with lots of other extra stuff) this problem did not occur.
Anyone got a clue to this problem?
Thanks
|
|
|
|
|
There is an article here by Joe Newcomer where he explains how to debug a release build. I suggest that you read that.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Hi,
I use a stored procedure for write to a Database.
When I execute the Stored Procedure, this Stored Procedure acknoledge with a int value if all are OK.
I would like to know how can I do for reading this value.
The value must be extract from the "Status".
You find my sample code:
//Initialize the connection with the Database RTLSQL1 ARCHIVES_NUM
//COM initialization
CoInitialize (NULL);
_ConnectionPtr m_pConn2("ADODB.Connection");
_ParameterPtr pParam2,pParam3;
try
{
//Check if I can create a instance for a connection into a db
HRESULT hr = m_pConn2.CreateInstance (__uuidof (Connection));
if (FAILED (hr))
{
// Automat_LOG_WITH_TIME(_T("DB : Can't create intance of Connection"));
}
else
{
// Automat_LOG_WITH_TIME(_T("DB : I can create intance of Connection"));
}
CString strFileName = "JA001206";
//Check if I can Open a session in the RTLSQL1 ARCHIVES_TVI
if (FAILED (m_pConn2->Open("provider=sqloledb.1;database=ARCHIVES_TVI;server=1.1.1.1;uid=Automat;pwd=Automat;network=dbmssocn","","",adConnectUnspecified)))
{
// Automat_LOG_WITH_TIME(_T("DB : Can't open datasource "));
// Automat_Send_SMS(_T("DB : Can't open datasource "),_T(""));
}
else
{
//Automat_LOG_WITH_TIME(_T("DB : I can open datasource "));
CString sT;
sT.Format("%d",1);
_variant_t varLiReturn;
int liReturn = -99;
_CommandPtr pCmd2("ADODB.Command");
pCmd2->ActiveConnection = m_pConn2;
//Store procedure for the DATABASE
pCmd2->CommandText = "StartFileNumV3";
pParam2 = pCmd2->CreateParameter ( _bstr_t ("FileName"), adVarChar,
adParamInput, strFileName.GetLength (), (_bstr_t) strFileName);
pCmd2->Parameters->Append ( pParam2);
pParam2 = pCmd2->CreateParameter ( _bstr_t ("AutomatNr"), adInteger,
adParamInput, sizeof(int), _variant_t (sT));
pCmd2->Parameters->Append ( pParam2);
pParam2 = pCmd2->CreateParameter(_T("Status"),adInteger,adParamOutput,sizeof(int),varLiReturn);
pCmd2->Parameters->Append ( pParam2);
_RecordsetPtr pRecordset;
pRecordset.CreateInstance(__uuidof(Recordset));
pRecordset = pCmd2->Execute(NULL, NULL, adCmdStoredProc);
//******************
//!!!!!!!! I don't know if it is correct to receive the return value
varLiReturn = pCmd2->Parameters->Item[_T("Status")]->Value;
Sleep(100); //ms
//Automat_LOG_WITH_TIME(_T("DB : The Store Procedure have been execute with success (StartFileNum)"));
//Close the DATABASE
if ( (m_pConn2->State & adStateOpen) == adStateOpen)
{
m_pConn2->Close();
// Automat_LOG_WITH_TIME(_T("DB : I can close datasource RTLSQL1 ARCHIVES_TVI"));
}
else
{
// Automat_LOG_WITH_TIME(_T("DB : I can't close datasource RTLSQL1 ARCHIVES_TVI"));
}
}
}
catch ( _com_error &e )
{
_bstr_t bstrSource (e.Source());
_bstr_t bstrDescription (e.Description());
CString sErrorDB;
sErrorDB.Format("DB : ERROR !!!!!\r\nException thrown for classes generated by #import\r\nCode = %08lx\r\nCode meaning = %s\r\nSource = %s\r\nDescription = %s\r\n", e.Error (), e.ErrorMessage (), (LPCTSTR) bstrSource, (LPCTSTR) bstrDescription);
// Automat_LOG_WITH_TIME(sErrorDB);
MessageBox (sErrorDB, bstrDescription,MB_OK);
}
catch (...)
{
TRACE ( "*** Unhandled Exception ***" );
}
Sleep(100); //ms
CoUninitialize();
youssef
|
|
|
|
|
I can't be arsed to read your code. But heres a snippet from some of my code that does what you want:
try {
_CommandPtr pCommand;
_ParameterPtr pRetVal;
pCommand.CreateInstance(__uuidof(Command));
pCommand->ActiveConnection = m_pConn;
pCommand->CommandText = "p_YourProc";
pCommand->CommandType = adCmdStoredProc;
pRetVal = pCommand->CreateParameter ( _bstr_t ("RETURN_VALUE"), adInteger, adParamReturnValue, 0);
pCommand->Parameters->Append(pRetVal);
pCommand->Parameters->Append ( pCommand->CreateParameter( _bstr_t ("YourParamIn"),adInteger,adParamInput,0 ,_variant_t(lTicketId)));
pCommand->Execute(NULL, NULL, adCmdStoredProc);
lSuccess = (DWORD) pRetVal->GetValue();
} catch (_com_error e)
{
}
Signature space for rent. Apply Within.
|
|
|
|
|
Hi, thank for the answer but I can't receive the return value.
lSuccess is allways null.
best Regards
youssef
|
|
|
|
|
paste the source of your stored procedure.
STL is a religeon. Enquiries to Reverend Christian Grauss
|
|
|
|
|
Use My class CADODatabase, You have the CADOCommand and CADOParameter Class...
For other side, if you want to return a value by the parameter, you mus tu use the following sintax in the stored prodedure
Create Procedure MyProc
@Param1 Integer,
@ParamRet varchar(100) output
AS
...
Select @ParamRect = "Hello World"
Go
Regards
Carlos Antollini.
www.wanakostudios.com
Sonork ID 100.10529 cantollini
|
|
|
|
|
Carlos Antollini wrote:
Select @ParamRect = "Hello World"
should be :
Select @ParamRect = 'Hello World'
SQL server is picky about that.
But he wanted a procedure's return value, not to return a value. Theres a difference(!)
STL is a religeon. Enquiries to Reverend Christian Grauss
|
|
|
|
|
If he wants to get the value returned by the stored procedure must to use the adParamReturnValue value.....
Check here
Best Regards
Carlos Antollini.
www.wanakostudios.com
Sonork ID 100.10529 cantollini
|
|
|
|
|
My original reply shows him how to do just that!!!
STL is a religeon. Enquiries to Reverend Christian Grauss
|
|
|
|
|
|
STL is a religeon. Enquiries to Reverend Christian Grauss
|
|
|
|
|
Hi!!!
Can anyone tell me the meaning of phrase "thread pool".
Actually i read certain articles on Server based applications at CP. Many people suggest that allocating one thread per user is a bad approach. People suggest that there are two other options one is I/O completion ports and the other is "thread pool"
Here i am unable to understand the meaning of "thread pool". As far as my vocabulary is concerned, the meaning of word pool is "standing water".
Please tell me the meaning of "thread pool"
|
|
|
|
|
You have a fixed number of threads. If the number of connections is less than the number of threads, you can give one thread per user. If the user count is higher the users are divided across the threads. This collection of threads is the thread pool. Like if the thread pool has 10 threads and you have to server 30 clients, each thread will handle 3 clients. This is a very simplistic explanation and the actual technical details, might be rather more complicated.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Oh thanks Mr.Nish for the reply, now i understand what is thread pool.
Also thanks for your "simple" artiles on Client-Server I/O. Really as a beginner I learn't a lot from them. I don't know why the rating is so low????
|
|
|
|
|
Nowadys, I often find that many softs use ini files, instead of dll files, to support multi-languages such as Flashget, Netants, Createinstall and so on. They employ a ini file to support another language, and need not modify the exe file. As a result, this method is better than the former. But I can not think of how to do it. Can you give me a favour?
Thank you.
|
|
|
|
|
I forget the names, but Microsoft provides heaps of API calls for ini files. Nevertheless, C++ iostreams are more than up to the task if you don't mind doing a little parsing.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
If you are asking what the INI functions are, here you go:
GetPrivateProfileString
GetPrivateProfileInt
GetPrivateProfileSection
GetPrivateProfileSections
GetPrivateProfileStruct
as well as the WritePrivateProfileXXX versions of all of these functions.
I would not reccomend trying to parse these files yourself as the API functions provide quite a bit of error checking and handling for you.
If you are wondering how to use this data in your program, I would create a set of global variables that have IDS associated with them, and the IDS will have the corresponding string in the ini file.
I would recommend that you look into string tables and create a resource only DLL in order to hold these Multi-language strings. You can create a string table with multiple LCID or locale IDS, that are associated with different langauges. Then you would create all of the string entries in this table, and you would only be responsible for selecting the correct LCID. When you load the string from the table it will get the correct one for you.
This also solves the problem from managing the different number of ini files, and prevents users from messing around and being able to edit these files.
Good Luck!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thank you very much. I had known how to support multi-languages with dlls. But nowadays, I see many softs use ini files instead of dlls, so i think it must has some good things, or they will not do this. I also find that they also use the code_page. How to modify the code_page dynamicly?
thank you very much.
zl
|
|
|
|