|
|
|
Karthikeyan U wrote: CXan i get the VC++ Tutorial
on what topic???
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Karthikeyan U wrote: CXan i get the VC++ Tutorial
Yep, see here[^]
|
|
|
|
|
here[^]
and don't forget : SPEAK ENGLISH !!!!
|
|
|
|
|
|
Hello all,
i want to be able to read any file in binary mode and put the files content into a char array, but it just won't work except of text files. How can this be done?
Thanks in advance
<br />
char* Files::ReadFile(const char* file) {<br />
ifstream::pos_type size;<br />
char* file_array;<br />
ifstream file (file, ios::in|ios::binary|ios::ate);<br />
if (file.is_open())<br />
{<br />
size = file.tellg();<br />
file_array = new char[size];<br />
file.seekg (0, ios::beg);<br />
file.read (file_array, size);<br />
file.close();<br />
<br />
return file_array;<br />
}<br />
return "Unable to open file";<br />
}<br />
|
|
|
|
|
nmx_de wrote: but it just won't work
Please, when you have a problem, explain it clearly. " It does't work" is very unclear, it can be anything. We cannot guess what the problem is just by looking at the screen.
|
|
|
|
|
Sorry for that. Thought it would be clear as i might not be the only one ever who tried to read a file into an array.
When I read a text file, I get the content of the file properly.
When I read another file (for example pdf), i only get an output like this:
<br />
%PDF-1.5<br />
$??<br />
Maybe it's an encoding problem, because the string is follow by some special characters. (Took a look at it in UltraEdit)
<br />
%PDF-1.5<br />
%âãÏÓ<br />
149 0 obj <</Linearized 1/L 1097<br />
...<br />
Is it possible only to read the binary value of the file?
Regards, n.
|
|
|
|
|
thats right... if you write the file_array as that type of file say 1.pdf then if u open the file then you can get the excat data...
Do your Duty and Don't expect the Result
|
|
|
|
|
Wow, seems to be one of my bad hair days.
I still missed to provide some information. I don't want to have a pdf file (or any other binary file) as a result. I only want to get the binary representation of the file. And this has to be some kind of string or char array.
|
|
|
|
|
nmx_de wrote: I only want to get the binary representation of the file. And this has to be some kind of string or char array.
No, a binary file contains junk characters and if you try to display it, you will have junk characters on the screen. Try to open the file with notepad and you will see what's inside.
And what do you mean by 'binary representation' ?
|
|
|
|
|
What are you trying to do exactly ? And what is the purpose ?
It's normal that if you try to display the contents of a binary file, you will have junk characters. That's simply because the purpose of a binary file is not to be readable (by a human I mean). So, what did you expect ?
|
|
|
|
|
What did you think you were going to get? That's what a binary file is.
Open it in any hex reader (or visual studio -- do file->open and select "Open As" = binary).
earl
|
|
|
|
|
I hope you are getting some junk value... in file_array for non text files..
if so, its obvious... because you are trying to view char value which is not char...
But for text files the data are in the form of char
Do your Duty and Don't expect the Result
|
|
|
|
|
I frequently use SetRedraw(FALSE) -> do drawing stuff -> SetRedraw(TRUE), but I sometimes have an outer drawing loop that does this, which calls, as part of the drawing, something else that also turns off/on redrawing, thus overriding the 'outer' loop's redraw flag. I have wondered if anyone knows of any way of determining the current value of the redraw flag for a window?
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
|
hello everyone,
I need to assign my App to some protocol like this:
I am on a website that contains <A HREF="someprotocol://someaddr">
it will load the program and pass this as the command line
-- modified at 6:29 Tuesday 25th July, 2006
|
|
|
|
|
hell_admin wrote: I need to assign my App to some protocol like this:
I am on a website that contains <A HREF="someprotocol://someaddr">
it will load the program and pass this as the command line
This is just a guess, but try merging the following into your registry:
[HKEY_CLASSES_ROOT\someprotocol\shell\open\command]
@="\"C:\\Program Files\\somefolder\\someprog.exe\" %1"
|
|
|
|
|
You're not so far from the truth
here's result maybe someone needed:
bool SetMoniker()
{
CString url = _T("your protocol");
CString def = _T("URL:someproto"); //can change after URL:
TCHAR app_path[_MAX_PATH+1]=_T("\0");
GetModuleFileName(NULL,app_path,_MAX_PATH);
CString icon(app_path);
icon += _T(",0");
CString command(app_path);
command = _T("\"") + command + _T("\"");
command += _T(" \"%1\"");
HKEY key;
if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_CLASSES_ROOT,_T("someproto"),0,0,REG_OPTION_NON_VOLATILE,KEY_WRITE,0,&key,0))
{
RegSetValueEx(key,_T("URL Protocol"),0,REG_SZ,(BYTE*)url.GetString(),(DWORD)( url.GetLength()*sizeof (TCHAR)) );
RegSetValueEx(key,NULL,0,REG_SZ,(BYTE*)def.GetString(),(DWORD)( def.GetLength()*sizeof (TCHAR)) );
HKEY icon_key;
if( ERROR_SUCCESS == RegCreateKeyEx(key,_T("DefaultIcon"),0,0,REG_OPTION_NON_VOLATILE,KEY_WRITE,0,&icon_key,0))
{
RegSetValueEx(icon_key,NULL,0,REG_SZ,(BYTE*)icon.GetString(),(DWORD)( icon.GetLength()*sizeof (TCHAR)) );
RegCloseKey(icon_key);
}
HKEY com;
if( ERROR_SUCCESS == RegCreateKeyEx(key,_T("shell\\open\\command"),0,0,REG_OPTION_NON_VOLATILE,KEY_WRITE,0,&com,0))
{
RegSetValueEx(com,NULL,0,REG_SZ,(BYTE*)command.GetString(),(DWORD)( command.GetLength()*sizeof (TCHAR)));
RegCloseKey(com);
}
RegCloseKey(key);
return true;
}
return false;
}
|
|
|
|
|
Hello:
I want to change wma to wav,I find it difficult.
Who know the source code about it, pls tell me.
Thanks
|
|
|
|
|
you asked this 2 hours ago... wait a little dude
|
|
|
|
|
toxcct wrote:
tooo -> good .. atleast you stop getting mad!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I guess that he dont ask this question again because he knows you are here
|
|
|
|
|
it's not what he should tell himself
people post because they have a question to ask... but once the thread is started, you have to continue to discuss on the same thread, not asking and asking until you get a response
|
|
|
|