|
The startup code is what makes you code into a windows-specific program.
You can get away without it, if your program e.g. gets some command-line arguments, reads a certain file and writes it back.
As long as you stick to old c-lib or C++-lib functions, there is no need to be windows proprietary.
If you want to read more, MSDN has topics about WinMain, CWinApp and "General MFC topics".
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Hello,
I have a CDatabase object.
CDatabase CurrentDatabase;
The table has columns LOCATION,PRODUCTS,t,Demand
In the following "FirstQuarter" is the variable which will have the sum of Demand.
CString Query = CString("SELECT SUM(Demand) as ") +
"FirstQuarter" +
" FROM " +
TableDemand +
"WHERE LOCATION = Mumbai"+
"AND PRODUCT = LPG +
"t = Jan OR t=Feb OR t=Mar";
CurrentDatabase.ExecuteSQL(Query);
Now how can I get this variable FirstQuarter in my own variable?.
Pritha
|
|
|
|
|
_RecordsetPtr cReadText::GetRecordset(_bstr_t SQL)<br />
{<br />
<br />
pCommand.CreateInstance (__uuidof (Command));<br />
pCommand->ActiveConnection = m_pConn; <br />
pCommand->CommandText = SQL; <br />
pRecordset.CreateInstance (__uuidof (Recordset));<br />
pRecordset->CursorLocation = adUseClient;<br />
pRecordset->Open ( (IDispatch *) pCommand, vtMissing, adOpenStatic,adLockBatchOptimistic, adCmdUnknown);<br />
<br />
MessageBox(pRecordset->Fields->GetItem("FirstQuarter")->Value);<br />
return pRecordset;<br />
<br />
}<br />
try this,
i Hope this can help you.
|
|
|
|
|
Hello,
I have sort of understod but can you tell me the which type of objects are these pCommand,pRecordset .
Is _RecordsetPtr a MFC class ?
And how can I connect my object(of class CDatabase) with all of these objects?
Thanks
Prithaa
|
|
|
|
|
Hi, i am sending these types:
<br />
_ConnectionPtr m_pConn;<br />
_RecordsetPtr pRecordset;<br />
_CommandPtr pCommand;<br />
<br />
these code helps you to understand:<br />
<br />
<br />
void cReadText::ConnectionAdo() <br />
{<br />
bConnected = true;<br />
<br />
try <br />
{<br />
HRESULT hr = m_pConn.CreateInstance (__uuidof (Connection));<br />
<br />
if (FAILED (hr))<br />
{<br />
AfxMessageBox ("Can't create intance of Connection");<br />
}<br />
if (FAILED (m_pConn->Open (_bstr_t("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = <big>EmailReminder.mdb</big>;"),<br />
_bstr_t (""), _bstr_t (""), adModeUnknown)))<br />
{<br />
AfxMessageBox ("Can't open datasource");<br />
} <br />
}<br />
catch( _com_error &e )<br />
{<br />
_bstr_t bstrSource(e.Source());<br />
_bstr_t bstrDescription(e.Description());<br />
TRACE( "Exception thrown for classes generated by #import" );<br />
TRACE( "\tCode = %08lx\n", e.Error());<br />
TRACE( "\tCode meaning = %s\n", e.ErrorMessage());<br />
TRACE( "\tSource = %s\n", (LPCTSTR) bstrSource);<br />
TRACE( "\tDescription = %s\n", (LPCTSTR) bstrDescription);<br />
AfxMessageBox ((LPCTSTR) bstrDescription);<br />
AfxMessageBox ((LPCTSTR) e.Source());<br />
<br />
<br />
bConnected = false;<br />
<br />
}<br />
catch (...)<br />
{<br />
bConnected = false;<br />
}<br />
<br />
<br />
}<br />
<br />
void cReadText::RunCammand(_bstr_t SQL)<br />
{<br />
<br />
m_pConn->Execute(SQL,NULL,adExecuteNoRecords);<br />
<br />
}<br />
<br />
_RecordsetPtr cReadText::GetRecordset(_bstr_t SQL)<br />
{<br />
<br />
pCommand.CreateInstance (__uuidof (Command));<br />
pCommand->ActiveConnection = m_pConn; <br />
pCommand->CommandText = SQL; <br />
pRecordset.CreateInstance (__uuidof (Recordset));<br />
pRecordset->CursorLocation = adUseClient;<br />
pRecordset->Open ( (IDispatch *) pCommand, vtMissing, adOpenStatic,adLockBatchOptimistic, adCmdUnknown);<br />
return pRecordset;<br />
<br />
}<br />
<br />
|
|
|
|
|
Hi All,
Please help me to solve my problem.
I've an MFC ActiveX control(.OCX) and i created this control in one of my Extension Dll's View class(derived from CView).This view has been placed in the SDI Splitter window application as one of the view.Every thing is working fine but when i close the Application window i'm getting the Assertion in "Release" Configuration but the assertion is not in "Debug" configuration.when i check with message boxes ,all the destructors are called in order. After all destructors completed i'm getting Assertion.
Can any one give me the Solution for my problem. Thanks in Advance.
|
|
|
|
|
|
You can use AfxMessageBox function to deflate the error code.
|
|
|
|
|
i configured fisrt service failure action of "alerter" servie as "Action Run Command" with commandline "C:\\myfile.exe" ,using services.msc under winxp .
i tried to retrieve the filename using the following code ...
int main()
{
BYTE* Buf = NULL ;
DWORD dwNeeded = 0 , dw = 0 ;
SC_HANDLE hSCManager , hService ;
hSCManager = OpenSCManager( NULL , SERVICES_ACTIVE_DATABASE , SC_MANAGER_ALL_ACCESS ) ;
hService = OpenService( hSCManager , "Alerter" , SERVICE_ALL_ACCESS ) ;
QueryServiceConfig2( hService , SERVICE_CONFIG_FAILURE_ACTIONS , (LPBYTE)Buf , 0 , &dwNeeded ) ;
printf( "BufSize = %d\n" , dwNeeded ) ;
Buf = new BYTE[ dwNeeded ] ;
if( QueryServiceConfig2( hService , SERVICE_CONFIG_FAILURE_ACTIONS , (LPBYTE)Buf , dwNeeded , &dw ) )
{
for( int i = 0 ; i < ((SERVICE_FAILURE_ACTIONS*)Buf)->cActions ; i ++ )
{
if( ((SERVICE_FAILURE_ACTIONS*)Buf)->lpsaActions[ i ].Type == SC_ACTION_RUN_COMMAND )
{
if( ((SERVICE_FAILURE_ACTIONS*)Buf)->lpCommand )
{
printf( "Actions : %d\nFile : %s\n" , ((SERVICE_FAILURE_ACTIONS*)Buf)->cActions , ((SERVICE_FAILURE_ACTIONS*)Buf)->lpCommand ) ;
}
}
}
}
printf( "%d" , (sizeof(SC_ACTION) )) ;
if( Buf )
delete[] Buf ;
CloseServiceHandle( hService ) ;
CloseServiceHandle( hSCManager ) ;
}
i got the output
BufSize = 78
Actions : 3
File :
//can any one tell me where is the problem in my code ? why i was unable to retrieve filename ?
Thanks & Regards
|
|
|
|
|
How can I intercept the media stream when an application like media player starts playing a movie, so that the encoded stream can be send to a remote client?
|
|
|
|
|
I don't know about intercepting a media stream - that's a hack.
You can, however, use the Windows Media SDKs[^] to manipulate media streams
however you need to.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How can I register a perticular extension files with my application ? It is a dialog based application, so i can't use RegisterShellFileTypes. Please tell me the other way.
|
|
|
|
|
Hi Friends
In my program contains one main window and too many child windows arranged horizontally to fill the whole main window. I like to draw a rectangle in main window. But it not seen properly, i think rectangle is painted behind the child windows. How to paint rectangle in front of child windows.
please help me !!!
thanks in advance
-RisKhan-
|
|
|
|
|
Draw Rectangle on your rootDC handle
Is this your answer?
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
Draw rectangle on your rootDC(main) handle.
Is this your answer??
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
You draw on the main window now whats your problem you cant see it?
|
|
|
|
|
Hi hamid
Actually the rectangle is shown behind the child windows. If i put a MsgBox in OnPaint i can see well.
-RisKhan-
|
|
|
|
|
Thats why i told you put it on your rootdc(main screen) handle
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
Thats why i told you put it on your rootdc(main screen) handle
Do you have check it?
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
Why you send dobule posts?
|
|
|
|
|
I dont know.
Nut when i am posting it shows some error message that message not send and when i send it again then it will be sent.
and in Message list it display two times.
Is this a website problem?
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
You can write to Suggestions and Bug Reports forum if you think its a problem for you.
|
|
|
|
|
|
|