visual-c++

Same simple source code, different binaries on Windows

Hi all, I have a question about the source-code binary on Windows. #include <stdio.h> int main() { printf("Hello, world!\n"); return 0; } The same source code, I compiled twice on Windows (VS 2008 Cmmand Prompt: "CL"), but I got different binaries. cl new.cpp Can you guys tell me why, and how to avoid that? Thanks. Pet...

Small issue with creating a process ( CreateProcess or ShellExecuteEx) with parameters (fixed)

Edit : Fixed, the issue was with the spawned EXE that did not handle the parameters properly (perl script that was byte compiles) Thanks again. Max. (probable duplicate of http://stackoverflow.com/questions/1135784/createprocess-doesnt-pass-command-line-arguments) Is there a difference between passing an argument vs. passing a par...

C standard library corner case

Is the following program a valid C program? #include <stdio.h> int main() { fwrite("x", 1, 1, stderr); fflush(stderr); fgetc(stderr); fwrite("y", 1, 1, stderr); return 0; } Notice that I try to read from stderr. When I compile it in Visual C++ 2008, and run it, I get the following output: xy which makes sense....

Use fprintf to memory stream

I have a vc++ method that uses fprintf to write values to a file in the hard disc. I want to change this method so that instead of writing the values to disc, I want to return a pointer to the data. I know in advance the size I have to allocate. Is there any way to pass a memory stream or unsigned char pointer to fprintf? thanks ...

Launching external application and block current application till the launched application quit

I am not sure whether there is a way to Launch an external application, and block current application till the launched application had quit. Currently, I am using the following non-blocking method (MFC) to launch std::string str = "Notepad2.exe"; // Non-blocking. Return immediately. WinExec(str.c_str(), SW_SHOW); ...

lambda expression (MSVC++ vs g++)

I have the following code #include <algorithm> #include <iostream> #include <vector> #include <functional> int main() { typedef std::vector<int> Vector; int sum=0; Vector v; for(int i=1;i<=10;++i) v.push_back(i); std::tr1::function<double()> l=[&]()->double{ std::for_each(v.begin(),v.end(),[&](int n){sum += n; /...

What are these odd files added to my Visual Studio MFC project?

Hi, I have a visual studio solution where one of the projects has somehow acquired several .bin files. They are named bin00001.bin, bin00002.bin, etc... and contains some kind of registry information. The contents of these files are one section repeated a number of times. bin00001.bin: HKCR { NoRemove AppID { '%APPID%'...

How to create BitMap Images using different colors in VC++?

Hello Friends.... I'm trying to develop a Desktop application using VC++ and MFC I'm new to it. Please help me.. ...

How to fill memory fast with a `int32_t` value?

Is there a function (SSEx intrinsics is OK) which will fill the memory with a specified int32_t value? For instance, when this value is equal to 0xAABBCC00 the result memory should look like: AABBCC00AABBCC00AABBCC00AABBCC00AABBCC00 AABBCC00AABBCC00AABBCC00AABBCC00AABBCC00 AABBCC00AABBCC00AABBCC00AABBCC00AABBCC00 AABBCC00AABBCC00AABBCC0...

Switch structure in C++ not working

#include<iostream> #include<stdio.h> using namespace std; void student_array(); void query(); void show_arr(); void student_entry(); struct student { char name[80]; char f_name[80]; char the_class[3]; char grade[2]; }; student std_arr[10]; char action; int count; int main() { cout<<"add 1st student"<<endl; st...

How to share a class in a Visual C++ DLL with C#?

I wrote my program in C++ and exported it as a DLL. I have a C# WPF GUI and I want to import the DLL to do the processing. I am very new to C#. How can I use the C++ class in C#? I know I can't just use the .h file. Because I used pointers in C++, in C# I couldn't use pointers. That's why I got confused. Like in C++ i used char* instea...

Print HWND to messagebox

How to print HWND value to MessageBox in visual c++? Update: I tried to print the handle ID to a messagebox, but instead it appears with Chinese characters. Here's the code I'm working on .. char szBuff[64]; sprintf(szBuff, "%p", m_hWnd); MessageBox(NULL, LPCWSTR(szBuff), L"Test print handler", MB_OK); ...

how to code thread synchronization using any method - eg ..Cevent

hello there I am trying to code a simple application which would help me in reading from a serial port and write to the same serial port using a single thread ...so could someone please help me to manage the synchronization between the threads.heres the source code- the whole project file in Visual studio 6 - http://rapidshare.com/files/...

GetObject - GetObjectA linker error

Hi, In my project I have a function named GetObject that is wrapped in one of my classes in my static library. When I call the function in another project that is using my library, I got this error: Error 1 error LNK2019: unresolved external symbol "public: class hamur::HamurObject * __thiscall hamur::HamurWorld::GetObjectA(class s...

VC++ Redirect Input/Output on Windows Interface

I am new to C++ and I need to direct my Input and Output to the window screen. For example if I write a simple program in C++ include using namespace std; int main () { int i; cout << "Please enter an integer value: "; cin >> i; cout << "The value you entered is " << i; return 0; } and we get I/O on the command prompt. But ...

How to migrate/convert a code of C++ ,built on Borland 2007 to Visual Studio 2010

Please guide me, as how to convert a C++ code of Borland 2007 in to Visual Studion 2010 code. I just need to ask, whether to write all th code again for 2010 or is there any shortcut for this conversion/migration. ...

Convert char[] to LPCWSTR

Can anyone help me to correct this code: char szBuff[64]; sprintf(szBuff, "%p", m_hWnd); MessageBox(NULL, szBuff, L"Test print handler", MB_OK); The error is, it cant convert the 2nd parameter to LPCWSTR. ...

codejock/MFC double key shortcuts

Hello, I want to use double key shortcuts like in MS Visual Studio but I have problems defining them. I use CodeJock and therefore the CXTPShortcutManager. If I manually assign a shortcut e.g. "Ctrl+K, Ctrl+C" directly in the program for a menu action it works properly. However, I was unable to define such a double key shortcut within...

windows anti virus process access level... win32 C++

Possible Duplicate: How can I keep Task Manager from killing my program? how to create such a process via win32 C++ ??? does it require some kernel mode? If you try to close the process of a typical anti virus software from task manager or form processxp it fails... I am looking for a way to make such a process that the use...

Is the error C1083 cannot open compiler generated file 'somePath\someFile.cod" related to Whole Program Optimization?

Hi, When I build I find I'm getting errors about missing cod files. The compiler seems to be trying to link to a lib that had some flag set when it was built to output .cod files. I don't see why the cod files are needed though to link, shouldn't the lib be enough? Thanks ...