|
It actually all depends on the project requirements, but I suppose its better to create projects with UNICODE defined and keep your textual data in unicode format. Prefered in my opinion should be UTF-8 which uses less space.
If you are loading a text file you should somehow know its encoding type. If you are using Notepad to save text in Unicode format then file contains some extra information bytes about actual encoding type - it is easy to see them in binary file view. Some info on actual notepad format encoding can be found here:
http://blogs.msdn.com/michkap/archive/2007/04/22/2239345.aspx[^]
There are some other errors in your code that might be the cause of the errory you describe. For example ftell() return length of the file in bytes..., here is a code I got working quite well:
wchar_t *gg;
FILE *wfile;
wfile = _wfopen(L"c:\\ReadMe.txt",L"r");
fseek(wfile,0,SEEK_END);
int num = ftell(wfile);
fseek(wfile,2,SEEK_SET);
int buffSize = sizeof(wchar_t)*(num/2+1);
gg = (wchar_t*)malloc(buffSize);
memset(gg, 0, buffSize);
fread(gg,sizeof(wchar_t),(num-1)/2,wfile);
fclose(wfile);
|
|
|
|
|
In my program, I need to look a directory and copy the filenames in that directory and display the same in my own listbox for a User to select. I want the finding and copying the files names to be done without a Users intervention - strictly behind the scenes activity. Anyone know how I can do this. (VS2008 C++ in MFC.)
Code would be nice. I used CString extensively.
Thanks in advance.
|
|
|
|
|
Do you need to DlgDirList or FindFirstFile/FindNextFile?
|
|
|
|
|
Larry Mills Sr wrote: display the same in my own listbox for a User to select
WIN32_FIND_DATA would be one of the options along with FindFirstFile etc.
Larry Mills Sr wrote: I want the finding and copying the files names to be done without a Users intervention - strictly behind the scenes activity
didn't get how would the user be intervening in this process of finding the files once you have the name of the directory and so it's path.
Larry Mills Sr wrote: Code would be nice. I used CString extensively.
I have just started working on your requirement. Would give you an optimized code soon that is specific to VS2008 C++ in MFC. You can transfer some amount [in cash please] to my account for the work that I do for you.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
modified on Friday, May 2, 2008 8:47 AM
|
|
|
|
|
_AnShUmAn_ wrote: I have just started working on your requirement. Would give you an optimized code soon that is specific to VS2008 C++ in MFC. You can transfer some amount [in cash please] to my account for the work that I do for you.
don't put you account number publicly , hacker migth hack it
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Use this code to find all files in a directory:
CString szFile, szDir = _T("D:\\CodeProject\\Trial\\res\\*.*");
CFileFind CFind;
BOOL bFound = CFind.FindFile(szDir);
while(bFound)
{
bFound = CFind.FindNextFile();
szFile = CFind.GetFileName();
CString ext3=szFile.Right(3);
CString ext4=szFile.Right(4);
if(!szFile.IsEmpty() && (szFile.GetLength()>4))
{
}
}
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Thank you very much.
A C++ programming language novice, but striving to learn
|
|
|
|
|
also try using multithreading extensivly
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Hi experts,
I have one application that enumearates ports..
when i buld my application and execute it runs fine..
but when i copied it to other PC
or another User of my PC then it gives me a exception
" The application failed to initialize properly (0x8000003). becoz of Congfiguration is incorrect.."
can anyone help me..its urgent...
what should I do?
Thnaks in advance..
|
|
|
|
|
Try decreasing the desktop resolution. Applications fail to initialize properly at very high screen resolutions. Also, try executing the application with different desktop wallpapers.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
ok
thanks for reply..
I already check all these things...
and my application is console based ..
so i think there is no need to change display settings,.
is there any other solution>
or any settings in VC++ project settings have to do?
reply.
|
|
|
|
|
Right now, with the information that you've given, changing the desktop wallpaper is the only solution I know.
If you want a more proper solution, give more details. Read the sticky post (guidelines) at the top of this forum, which says "How to get an answer to your question". Follow the guidelines and you'll get an answer.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Member 3220373 wrote: so i think there is no need to change display settings,.
That's because it was a joke.
Member 3220373 wrote: is there any other solution>
Is the application compiled in debug or release mode? Does this other machine have all the necessary DLLs installed? See here for more.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You should look for all the DLL's or modules that your application is using to be loaded in the other computer, do you have some registry keys that are being used? and do those keys are in the other computer? do you have any configuration file that you are accessing without controlling the result and the file is not there? have you searched for that error code in google or in MSDN? Are you using an activeX control in your application? and if you are using it, have you registered it on the other computer? The operating system version is the same? it can be that you are using an API that is not present in the other OS...
And tons of things more...
Why don't you post something more accurate?
PS: if you are not getting anything, then try it in the old-school way: remove/comment parts of the code until you can see why do it happen...
Good luck...
|
|
|
|
|
Joan Murt wrote: ...try it in the old-school way: remove/comment parts of the code until you can see why do it happen...
Unfortunately, this has been replaced with Internet queries.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
ah... yes, of course...
|
|
|
|
|
This problem occurs when the side-by-side assemblies listed in the application manifest aren't present. Most likely this is the C++ runtime if you're using Visual Studio 2005 or later. Use vcredist_x86.exe to install the runtime.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Excuse my ignorance on this matter ...
I am trying two write a small app that copies files from an Intranet server. If I access the directory on the server using Internet Explorer I get a Web based directory listing. I think it's an apache/Linux server. I would like to scan through the directory like you can using FindFirstFile and FindNextFile (which does not work), but I can not see how to do.
My expertise is C++ / MFC.
modified on Friday, May 2, 2008 8:58 AM
|
|
|
|
|
Anorexic Tribble wrote: ...FindFirstFile and FindNextFile (which does not work),
They do if used correctly. Define "does not work."
Anorexic Tribble wrote: My expertise is C++ / MFC.
So have you tried CFileFind ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
CFileFind is just a C++ wrapper around FindFirstFile and FindNextFile. Hence exacly the name result. That is they fail to find any files.
If I do a DIR on the directory it can not find the directory, yet Internet Explorer can. There must be another layer of protocol sitiing in the way.
|
|
|
|
|
Anorexic Tribble wrote: That is they fail to find any files.
If FindFirstFile() is failing, why are you not calling GetLastError() to find out why?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Error code is 0x4CF "The network location cannot be reached."
Yet I can see it with Internet Explorer.
|
|
|
|
|
So what does your code look like that is producing this error?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
#define INTRANET_STORE "//server5.asd.co.uk/data/docs"
BOOL Found;
CFileFind Finder;
Found = Finder.FindFile((CString)INTRANET_STORE + (CString)"/*.pdf");
while (Found)
{
Found = Finder.FindNextFile();
m_File_List.AddString(Finder.GetFileName());
}; // ENDWHILE
|
|
|
|
|
So have you tried using a Windows style UNC? The Unix style *should* work, but you never know...
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|