|
VC_RYK wrote: ...how to debug and see what is happening behind if i start this service.
See here and here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
when i am trying to write log file using
CRITICAL_SECTION myCS;
void WriteLog(char* pMsg)
{
// write error or other information into log file
::EnterCriticalSection(&myCS);
try
{
SYSTEMTIME oT;
::GetLocalTime(&oT);
FILE* pLog = fopen(pLogFile,"a");
fprintf(pLog,"%02d/%02d/%04d, %02d:%02d:%02d\n %s\n",oT.wMonth,oT.wDay,oT.wYear,oT.wHour,oT.wMinute,oT.wSecond,pMsg);
fclose(pLog);
} catch(...) {}
::LeaveCriticalSection(&myCS);
}
it is crashing over ::EnterCriticalSection(&myCS); so can you help to atleast write a log file to know the arrival or removal.
|
|
|
|
|
VC_RYK wrote: ::EnterCriticalSection(&myCS);
How is myCS created/initialized?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi resolve this one but i am trying to install this service by following the steps what is given on MSDN but not get installed.
|
|
|
|
|
VC_RYK wrote: ...but not get installed.
Ok, so what's the problem? Your screen is too far away for me to see.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
For standard services, it easiest (at least in VC++ 6.0) to create an ATL COM service and remove what you don't want. I only used VS2005 while it was in beta and never tried to create a service with it but I'm guessing that functionality should (operative word) still be there.
|
|
|
|
|
Look here[^] for a nice tutorial on how to write services.
|
|
|
|
|
I was trying to update the statusbar information with the colour information of pixels.
Image is open in a view clas named CChildView, which is attached to a child frame of the MainFrame named ChildFrame.
What I was trying to Update it using a string, it keeps give me the error message:
Unhandled exception at 0x00402ca6 in ImageLab.exe: 0xC0000005: Access violation reading location 0xbaadf009.
and stopped at here:
CSimpleStringT& operator=( __in const CSimpleStringT& strSrc )
{
CStringData* pSrcData = strSrc.GetData();
CStringData* pOldData = GetData();
if( pSrcData != pOldData)
{
-> if( pOldData->IsLocked() || pSrcData->pStringMgr != pOldData->pStringMgr )
{
SetString( strSrc.GetString(), strSrc.GetLength() );
}
else
{
CStringData* pNewData = CloneData( pSrcData );
pOldData->Release();
Attach( pNewData );
}
}
return( *this );
}
|
|
|
|
|
I'm not sure about the code you posted but MSDN for VC++ 6.0 has a tutorial for updating from CMainFrame. Look up "CStatusBar"/"updating pane" for that.
However, since m_wndStatusBar is Protected, you will have to stand on your head a bit to get this to work from other classes. For simplicity, lets assume your updating the location of the mouse cursor in the MDI child view coordinates. You can get to the m_wndStatusBar by making it Public but that's not usually desireable so lets create a mutator for it.
In CMainFrame of an MDI app. Add an entry for the pane that will be filled with the coordinates. You would likely create a symbol for this for production but for now, just create an entry reusing the separator symbol and we'll just go for index 1 to speed this demo up.
// MainFrm.cpp
//...
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_SEPARATOR, // *** Added ***
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
//...
void CMainFrame::SetPaneText(const int nPane, const CString& sPane)
{
// Mutator for protected member
m_wndStatusBar.SetPaneText(nPane,sPane);
}
// MainFrm.h
...
public:
void SetPaneText(const int nPane,const CString& sPane);
// CYourView.h - Note: the placement may vary if conflicts arise
#include "MainFrm.h"
// Use the classwizard to create a WM_MOUSEMOVE handler
void CYourView::OnMouseMove(UINT nFlags, CPoint point)
{
CString sText;
CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();
if (pFrame) {
sText.Format(" X=%d Y=%d",point.x,point.y);
pFrame->SetPaneText(1,sText);
}
CScrollView::OnMouseMove(nFlags, point);
}
// End code
Not pretty but it works. However, I'm betting the Update Handler that is discussed in MSDN is the proper way to go so I would recommend trying that and see if it fits your needs. If not, this technique might get you by.
|
|
|
|
|
Hi All,
i'm using IXMLDOMDocumentPtr for loading xml and do operations on it.
when i run my application with purify it is showing a memory leak in CreateInstance & loadXML.
please give me a suggestion where am i wrong? or what changes i need to do.
here is my sample code:
BSTR bstrUserInputsXml=NULL;
{
CoInitialize(NULL);
IXMLDOMDocumentPtr pXMLDom=NULL;
hr=pXMLDom.CreateInstance( "Microsoft.XMLDOM" );
//hr=pXMLDom.CreateInstance( __uuidof(MSXML2::DOMDocument40));
if(FAILED(hr))
{
//cout<<"Failed to instantiate DOMDocument40"<<endl;
return="" -1;
="" messagebox(null,"failed="" to="" instantiate="" domdocument40","keytable.s",mb_ok);=""
="" ;
="" }
="" if(pxmldom-="">load("D:\\userinputs1.xml")!= VARIANT_TRUE)
{
//MessageBox(NULL,"Failed load xml string","KeyTable.s",MB_OK);
return ;
}
bstrUserInputsXml = pXMLDom->xml;
pXMLDom.Release();
CoUninitialize();
}
Thanks in advance.
Prashanthv
-- modified at 14:02 Friday 27th April, 2007
|
|
|
|
|
Are you sure there is a memory leak with that code snippet?
|
|
|
|
|
Hi all.
I need come function that is't member of MFC and can read chan from file, that stands in (x,y) coordinate.
|
|
|
|
|
david bagaturia wrote: that stands in (x,y) coordinate.
What do you mean by COORDINATE in a file?
You can use fseek() to go to a certain location in a file and then perform operations on the file data.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
First, it's OK to flame me for suggesting old C code, I'm leaving work for the weekend anyway
I assume the file is a text file containing text lines you want to read.
Further, I assume that the file in question isn't written i unicode.
One way:
Open the file with fopen()
Read textline by textline with fgets()
Close the file with fclose()
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
both return handle fail.
what does it mean?
I am using the encoder 9 sdk. I have pick the sample application which comes with sdk .
Now when i use the inbuitl sample . it encode the file
but when i use that one for changing the following things it gets return handle fail.
Look at the change:
In sample application
---------------------
if ( SUCCEEDED( hr ) )
{
hr = pSrcAud->SetInput(CComBSTR("C:\\InputFile.mpg"));
}
if ( SUCCEEDED( hr ) )
{
hr = pSrcVid->SetInput(CComBSTR("C:\\InputFile.mpg"));
}
my change
---------------
WCHAR * pwszOutFile = NULL;
WCHAR * pwszInFile = NULL;
for(int i=0;i<argc;i++)
{
if( 0 == _tcsicmp( argv[i], _T( "-i" ) ) )
{
i++;
if( i >= argc )
{
break;
}
hr = ConvertTCharToWChar( argv[i], &pwszInFile );
if( FAILED( hr ) )
{
break;
}
}
else if ( 0 == _tcsicmp( argv[i], _T( "-o" ) ) )
{
i++;
if( i >= argc )
{
break;
}
hr = ConvertTCharToWChar( argv[i], &pwszOutFile );
if( FAILED( hr ) )
{
break;
}
}
}
CComBSTR bsInputFile;
bsInputFile.Attach ( W2BSTR(pwszInFile ) );
if ( SUCCEEDED( hr ) )
{
<code> hr = pSrcAud->SetInput(bsInputFile);
}
I had try to find so many times in the google, but unable to find the solution.
the preparetoEncodemethod works for console but when i am using the same thing for the window.
it give me the E_UNEXPECTED result in the hr.
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
What is ConvertTCharToWChar?
Have you looked at bsInputFile in the debugger to see if it's valid?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: What is ConvertTCharToWChar?
HRESULT ConvertTCharToWChar( TCHAR * ptszInput, WCHAR ** pwszOutput )
{
int cchOutput = 0;
if( NULL == ptszInput || NULL == pwszOutput )
{
return( E_INVALIDARG );
}
#ifdef UNICODE
cchOutput = wcslen( ptszInput ) + 1;
#else //UNICODE
cchOutput = MultiByteToWideChar( CP_ACP, 0, ptszInput, -1, NULL, 0 );
if( 0 == cchOutput )
{
return( HRESULT_FROM_WIN32( GetLastError() ) );
}
#endif // UNICODE
*pwszOutput = new WCHAR[ cchOutput ];
if( NULL == *pwszOutput)
{
return( E_OUTOFMEMORY );
}
#ifdef UNICODE
wcsncpy( *pwszOutput, ptszInput, cchOutput );
#else //UNICODE
if( 0 == MultiByteToWideChar( CP_ACP, 0, ptszInput, -1, *pwszOutput, cchOutput ) )
{
SAFE_ARRAYDELETE( *pwszOutput );
return( HRESULT_FROM_WIN32( GetLastError() ) );
}
#endif // UNICODE
return( S_OK );
}
Have you looked at bsInputFile in the debugger to see if it's valid?
yes , The value comes valid.
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
Well if the string is valid at the time of the call, and it's exactly the same as when
you use the sample code, then it should work.
It's impossible for us to debug - you have to do it
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks for you nice smile .
but I really need your help can you give the proper time so can we seat together? for solving the problem?
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
If that's really the only change you made from the sample code, and the sample code worked,
then you should be able to debug it fairly easily.
I would start at the line you marked in red and comment it out and add the line from the working
code, like this:
//hr = pSrcAud->SetInput(bsInputFile); //Handle return hr=-2147012890
hr = pSrcAud->SetInput(CComBSTR("C:\\InputFile.mpg")); //this is a standard file
If it doesn't work, then something is broken somewhere else.
If it works, then switch the code to your new code:
hr = pSrcAud->SetInput(bsInputFile); //Handle return hr=-2147012890
//hr = pSrcAud->SetInput(CComBSTR("C:\\InputFile.mpg")); //this is a standard file
Put a breakpoint here and check bsInputFile in the debugger. It should be the EXACT string
that worked in the sample code ("C:\InputFile.mpg" in your posted code).
If the project is fairly small and you have a complete buildable solution for VS 2003 or below,
I can look at the code if you want to send it. Email me.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thank you very much for this guideline.
and support.
if this will not run then I will email you.
Thank you once again Dear Mark .
"Success lies not in the result , But in the efforts !!!!!"
Amit Mistry - petlad -Gujarat-India
|
|
|
|
|
I used OPENFILENAME structure and GetOpenFileName to retrieve the name of the file and other details. Is there a way where i can get the name of the folder in which the file that has been opened resides. I need the name of the folder without the path.
|
|
|
|
|
DWORD GetFullPathName(
LPCTSTR lpFileName,
DWORD nBufferLength,
LPTSTR lpBuffer,
LPTSTR* lpFilePart
);
Gets you the path of the file. Now you can use CString functions to extract the folder path.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Take a look at PathRemoveFileSpec[^]
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|