|
|
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
|
|
|
|
|
Hi,
I am developing an application in VC++ Windows Forms using Visual studio 2005. I need to generate reports for the application. I tried using Report Viewer control in it.
After surfing the net i got a piece of code for report viewers in C#. I tried changing the code according to Windows Forms syntax...
But it does not work...Please if any one could help me with this.
Thanx in advance
shraddha
|
|
|
|
|
and getting selected text from static controls or rich text control, I can get selected position but dunno how to get text
can anybody give me a clue
thanks in advance
|
|
|
|
|
CRichEditCtrl::GetSelText
CRichEditCtrl::GetTextRange
--
=====
Arman
|
|
|
|
|
|
Thanks, that's what I wanted
|
|
|
|
|
You're welcome
|
|
|
|
|
Hello,
I've been creating a new application, and as I'm learning how to use the new IDE I've made a mistake:
I have created a new dialog and the new files realted to the new class (*.cpp and *.h) have been created in the main folder of the application.
I wanted that pair of files inside a subfolder and I've moved them.
I've gone to the "solution explorer" and then I've removed those files and added them again.
Now it seems that each time I try to add a new function to one of those classes the VC++ generates again the original files placed in the wrong folder.
How can I solve this?
As always thank you in advance.
|
|
|
|
|
When you use the wizard to add a function, you'll find the name of the file that the function will be added to in an edit box near the bottom right.
Simply edit that to have the path to your file. We also have that problem, as our .sln and .vcproj files are in a bld subdirectory under the main project directory, and our sources are in a src directory under the main directory.
So when we add a function, the file name may appear as
myclass.cpp and we simply change it to
..\src\myclass.cpp
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
|
|
|
|
|
I've solved that a few minutes ago, only by resetting the computer...
Thank you for your feedback.
|
|
|
|
|
Hi.
I have manage to plot sin(x) by calling gnuplot but the display of the graph is only for a split second. How do I make the graph show longer or continue displaying until the 'x' button (exit) is clicked?
The following are my codes:
<br />
pid = _popen("wgnuplot.exe", "w");<br />
cfile = fopen("cSinx.txt", "r");<br />
if ((pid > 0) && (cfile > 0))<br />
{<br />
printf("Open file suceeded!\n");<br />
system("wgnuplot.exe cSinx.txt");<br />
_pclose(pid);<br />
}<br />
cSinx.txt is a file where I put the command
|
|
|
|
|
how can i link libws2_32.a to my project
tamer
|
|
|
|
|
*.a file are linux libraries or libraries for MinGW (as far as I know, but my knowledge there is a little bit limited). Which compiler are you using ? If you use one of the Visual studio IDE, you need to link to ws2_32.lib instead.
|
|
|
|
|
after complete a project,I am not careful to delete the Combo Box.
I place a new Combo Box before and modify the ID property which is same to
the deleted.
But after modified ,the Combo Box did not display the item.
(the project run on .NET)
|
|
|
|