If you have the program set to unicode, you need to use _wfopen_s to open the file, and the filename (OpenFile) needs to be specified as wchar_t something like wchar_t Myfile[] = "my_file.ext"; Then you should be able to use fgetwc to get the characters using ch = fgetwc( stream ); your should specify ch as wchar_t
malaugh
Posts
-
How can read a unicode text file as character by character? -
Displaying Chinese CharactersThe easiest way to handle this is to change the font to Aerial Unicode MS. This font is installed n all machines that have office or some office app, like Excel or Word. Its not a Guarantee for all machines. For the other you need to install some other Unicode font. You can do this by Changing the font properties on the main dialog box.
-
Error message running exeYour need to install the Microsoft run-time libraries on the new machine. The libary pack you need depends on your version of Visual Studio, for example, VS2005 needs the following to be installed. http://www.microsoft.com/downloads/en/details.aspx?FamilyID=32bc1bee-a3f9-4c13-9c99-220b62a191ee&displaylang=en Alternatively, you can compile the executable to use static libraries. Open Project->Properties, and select "use MFC in a static library" under General->Use of MFC, then go to Linker->General, go to "Delay Loaded DLLS" and uncheck the "inherit from parent" checkbox.
-
Write a function to cause a thread to waitAll the CPU cycles are going to reaing the clock over and over. If you want to be independant of windows, the function uSleep is Unix the equivelent of Sleep, just add
#ifndef WIN32 #define Sleep(x) uSleep(x * 1000) #endif
To the top of your code -
making ini file in Documents and Settings WritePrivateProfileString toI am trying to make an INI file in C:\Documents and Settings\All Users\Application Data\MyApp I know WritePrivateProfileString will write a new file if one does not exist, but if I try
#define INI_FILENAME "C:\\Documents and Settings\\All Users\\Application Data\\MyApp\\MyApp.ini"
WritePrivateProfileString("My Section", "My Name", "My Value", INI_FILENAME);
It will only make a new ini file if the directory exists. Is there a workaround for this? If not, how do I check to see if a directory exists, and make a new one?
-
Schedule events in CYou mean code to create a thread? just use DownlinkThread = CreateThread( NULL, // default security attributes 0, // use default stack size Func, // thread function 0, // argument to thread function 0, // use default creation flags &MsgThreadId); // thread identifier The thread function is WORD WINAPI Func( LPVOID lpParam ) { while(1) { Sleep(30 * 60 * 1000); } return(0); } Substitute CreateThread with pthread_create and Sleep with uSleep for the Linux version
-
Application upgradeShould be no problem at all. I write MFC applications and have both VS 6.0 and VS 2008 installed on my XP computer. If I open a 6.0 project with VS 2008, it gets automatically converted to the new project format.
-
Someone Please Help (WinPCap/TCP Capture)Did you look at this? It worked for me. http://www.tcpdump.org/pcap.htm[^]
-
Native c++ using VC++ 8.0I had the saem problem as you. I could not get my programs tio run on a machine with just the OS. Now I 1) Change the Project defaults in the General Section to "Use MFC in a static library" 2) Uncheck "Inherit from Parent or project defaults" in the linker Additional Library Directories section (gets rid of a warning). All my programs work on a machone with a "virgin" OS after these changes.
-
Dll and global variables.There may be a easier way to do this, but one way is to create global shared memory is to use CreateFileMapping on one DLL, and OpenFileMapping in the other. Pseudo-code is something like: DLL #1 ------ int *pMemory; hMem = CreateFileMapping(....."MySharedMemory"); pMemory = (int *)MapViewOfFile(hMem); pMemory = 3; DLL #2 ------- int *pMemory; int Value; hMem = OpenFileMapping(....."MySharedMemory"); pMemory = (int *)MapViewOfFile(hMem); Value = *pMemory; Note sure if this is 100% correct, its been a while since I used it. grep in codeproject for "Shared Memory with IPC with threads" to get more details.
-
Opening terminal windows from command line appMy mistake, I must have coded it wrong the first time. I tried it again using: ShellExecute(0,0,"myprogram.exe",0,0,SW_SHOWNORMAL); and it worked. I sued a more complex example last time, must be something to do with the options.
-
Opening terminal windows from command line appThanks. FYI I found another method. If you open a cmd window and type "start myprogram.exe", the program will start in another window, so in my program I used: system("start myprogram.exe"); I will your method also and see which works best.
-
taylor formulaI cannot guarenee its right, you will have to debug it yourself, but something to get you started #include int main(void) { double current = 1; double old = 0; int n = 1; int factorial = 1; while(fabs(current - old) > 0.05/100) { old = current; factorial *= ++n; current = pow(old, n) / factorial; } }
-
Mapping the Windows XP APIs to LinuxFor mapping windows threads to linux, take a look at this article http://www.ibm.com/developerworks/linux/library/l-ipc2lin1.html[^ For GUI, I wrote an article on using GTK on Linux and Windows, search for GTK in codeproject and you should find it.
-
Opening terminal windows from command line appI need to command line program that starts other command line applications in their own window. I can use spawn or ecec to run the programs but they run in the main window, not their own. I tried using ShellExecute, but I got a linker error. Does a DOS terminal window have a program name I can call using system or spawn? Any suggestions? Thanks
-
Can I change the priority of "main"I have a main program that creates some threads, then goes into an event loop. The structure is: main() { CreateThread.... CreateThread..... while(1) { WaitForSingleObject(Main_Event) .... do some processing.... } } I would like to increase the priority of "main" so that when "Main_Event" is sent, the threads suspend while main loop is processing. Any idea how I can do this?
-
can i create a dll, what includes other dlls?If you do not want to use "loadlibrary" see other reply) 1) You cannot set a path for a DLL, you must either have your new DLL in the same directory as the DLL you are calling, or put it in the windows/system32 directory. 2) You need to link the lib file. Either add the lib file using project properties or add following to your source file #pragma comment(lib,"DllName.lib") 3) Add the header file for the DLL to your source file.
-
Catching Key Event of an Edit BoxNot sure if this helps but you need to use this code to get return keys in your derived class. Maybe the same for your probem? UINT CEdit_xx::OnGetDlgCode() { return( CEdit::OnGetDlgCode() | DLGC_WANTALLKEYS ); }
-
Windos/CygwinYou could try compiling under windows, just select WIN32 Console application, add all your c files to the project, and compile. It may work of the program has no unix specific calls. If not, you need to install the GCC compiler. Google cygwin to get the files.
-
help with arraysyou need to replace the line test_score[i][j] = 0; with a formula that will give the chart in the answer for example test_score[i][j] = i + j; would give 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 think about it.