visual-c++

How to create custom clean (post-clean) event in Visual Studio 2008?

In our build process, for each project we use Post Build events to copy our executable files into a separate deployment directory. That works just peachy, but the problem is that we run into problems with stale files after performing a Clean Solution/Clean Project. I'd like to set up a "Clean" event that deletes the copied file and Vis...

Creating C++ DLLs with Visual Studio

I am creating a simple C++ DLL project using Visual Studio 2008 Express Edition. I have a few classes inside a namespace, and a few non-static functions and constructors inside it are declared with __declspec(dllexport). All those functions are implemented. I also have an extern "C" BOOL APIENTRY DllMain function which simply returns TR...

MFC - Check if Microsoft Word Program Exists

Hi, I was wondering if there is any way to figure out programatically if Microsoft Word (Word 2003) exists on the target PC. Creating this app on VS2005, C++. Thanks ...

Visual Studio 2005 - VC++ compiler C1001 on Windows 7

When I try to build a simple "Hello World" C++ app on Windows 7 Beta, using Visual Studio 2005 (VC++2005) I get a rather generic error C1001 error (Internal compiler error) The compiler seems to just crash, and Windows pops up its (un)helpful This program has stopped working dialog. The file it complains about is mcp1.cpp. Has an...

how to print Text on HBITMAP?

how to print Text on HBITMAP? how to attach HBITMAP into CImage Object? ...

Mis-indexed char[] arrays in Visual Studio 2005

I'm at a loss to explain what seems to be mis-addressing within the char[] arrays of a C++ class I've inherited. I'm using Visual Studio 2005 and have narrowed the problem down to this: MyClass.h: class MyClass { public: MyClass(); virtual ~MyClass(); void Reset(); // More member functions. . . char m_szString[128]; // Mo...

DECLSPEC_NOVTABLE on pure virtual classes?

This is probably habitual programming redundancy. I have noticed DECLSPEC_NOVTABLE ( __declspec(novtable) ) on a bunch of interfaces defined in headers: struct DECLSPEC_NOVTABLE IStuff : public IObject { virtual method1 () = 0; virtual method2 () = 0; }; The MSDN article on this __declspec extended attribute says that adding ...

Possible bug in _controlfp_s may not restore control word correctly

Hi All, I've stumbled across either a problem with _controlfp_s (Visual Studio 2008), or my understanding of it. I thought the first out parameter returned the control flags before changes of the other parameters are applied. Seems it returns the flags after the change. So, I thought the correct way to use it was like this: // Chop ...

Problem with SafeArray access using CComVariant

Hi, I have following block of code ///////////////////////////////////// CComVariant newVal; //pass the CComVariant and get the strings array!!! GetStrList(newVal); USES_CONVERSION; if (((newVal.vt & VT_ARRAY) == VT_ARRAY) && ((newVal.vt & VT_BSTR) == VT_BSTR)) { SAFEARRAY* paArray = newVal.parray; BSTR * str = NULL; SafeArray...

Why does this take so long to compile in VCC 2003?

My team need the "Sobol quasi-random number generator" - a common RNG which is famous for good quality results and speed of operation. I found what looks like a simple C implementation on the web. At home I was able to compile it almost instantaneously using my Linux GCC compiler. The following day I tried it at work: If I compile in V...

How do you disable CBitmapButton?

How do you disable CBitmapButton? I tried using m_bitmapbutton.EnableWindow(false); but it doesn't work. It still fires an event. What I'm trying to do is prevent Button A from firing Event A if Event B is executing (from Button B). So in Event B, I want to disable Button A. ...

Any way to see Debug output without Visual Studio?

Using MFC's TRACE macro or OutputDebugString from the Windows API, you can write to the output window of Visual Studio. Is there any way to see this output on a system where you don't have Visual Studio installed, and don't want to install it? ...

What is __unwind$ in a linker map file

For VS2008 (C++) generated linker map files, what does the symbol "__unwind$" mean? I have a good chunk of them in the linker map file for my app. I have a log which says a crash happens at a particular offset say 'x'. When I look at the linker map for this offset, I find this __unwind$41357 corresponding to the offset. Also generally ...

Problem in compiling in release mode --VC++

Hi All, I am compiling my project in the release mode in VC++. I have a .def file where i have declared the setLog and now i am getting following error Linking... Creating library Release/HKL.lib and object Release/HKL.exp HKL_libinterface.obj : error LNK2001: unresolved external symbol _SCTP_setLog@8 Please help me on the above to...

Python script at Visual C++ 2005 build step not spawning other processes.

I have the following post-build step in a VC++ 2005 project that calls a Python 2.5.1 script: postbuild.py postbuild.py does: import os os.system('cd') # cd is just a test, could be anything The process never starts, and it's the same with any other process I try, even using subprocess.call or Popen instead of os.system. Does anyo...

Sharing precompiled headers between projects in Visual Studio

I have a solution with many Visual C++ projects, all using PCH, but some have particular compiler switches turned on for project-specific needs. Most of these projects share the same set of headers in their respective stdafx.h (STL, boost, etc). I'm wondering if it's possible to share PCH between projects, so that instead of compiling e...

How to get around "Binary was not built with debug information"?

I'm trying to debug a C DLL that I'm using with a Delphi program. I built the DLL with Visual C++, with debug information enabled. I built the Delphi program with Delphi 2009, with debug information enabled. But apparently they use different formats, because when I try to attach the VC++ debugger to my program, it says "binary was not...

Windows Forms, tutorial?

Question: Looking for a simple, Windows Forms tutorial: Get some user input from a text box into a variable ...

Replacement for #import in Visual C++

We have large C++ project that we used to compile with the /MP switch to take advantage of multiple cores. However, we recently brought in some code that uses #import on a couple of tlb's, and #import is incompatibile with /MP, which means we are back to single threaded builds and a lot more time to get coffee. Any suggestions on how t...

How do I create a directory in a makefile

I'm using Visual Studio 2005 nmake, and I have a test makefile like this: sometarget: -mkdir c:\testdir I want to always create the directory, without having to specify 'sometarget'. For example, I can do this: !if [if not exist c:\testdir\$(null) mkdir c:\testdir] !endif But that requires two lines, where I really only want to...