visual-c++

How to convert _bstr_t to CString

I have a _bstr_t variable bstrErr and I am having a CString variable csError. How do I set the value which come in bstrErr to csError? ...

How to know the internet connection details using Visual C++ Win32 API

I have to create a log file for all internet connection made by PC. It should have details of the username, time of connection, etc. I do know about the InternetGetConnectedState() function which returns the bool value. Know how do I get the other details. Can some one help me out thanks in advance. I am using win32 API and visual c++. ...

How do I use _W64 and __w64 in VC++?

There's such thing as __w64 in Visual C++ 9. I came across it while trying to port my native C++ DLL to 64 bit. In particular in crtdefs.h there's this nice snippet: #if !defined(_W64) #if !defined(__midl) && (defined(_X86_) || defined (_M_IX86)) && _MSC_VER >= 1300 #define _W64 __w64 #else #define _W64 #endif #endif which if I get it...

Finding out the time taken to execute a function

I wrote a function to match fingerprint templates using VC++.NET. Now I want to know the time it takes to execute the function. I tried surrounding the function call statement with clock ( Standard C Library ) and computing the difference in the values returned. For some reason it always returns zero. Am I missing something here or ar...

Visual C++ debugger and BoundsChecker mystery

Hi everyone, Look at this screenshot of a Visual C++ debugger session: The execution point is now inside a virtual function. "mDb" is a reference to an object which is the member of that class. "mDb" has the type CDbBackend&. There is only one thread. The values in the red rectangles should be equal, ... but they're not. How can this...

Learning Windows Services with C++

Hi, Can you suggest a good book for learning Windows Services programming using C++? Thanks, ...

How do I trace into an externally-compiled lib in Visual C++

I built the non-dll version of OpenSSL on my windows box. Per the instructions I modified the build script to include debug symbols. I can link against them fine and they run. But when I try to step into an openssl function from my cpp code it just steps over. I know this is a total noob question but how do I fix this? I have all th...

How to statically link using link.exe

I've been trying to statically link against a C++ library called Poco on Windows using the Visual Studio 2008 command line tools. I build my program with: cl /I..\poco\lib /c myapp.cpp link /libpath:..\poco\lib myapp.obj PocoNet.lib This results in an exe that at runtime requires PocoNet.dll and PocoFoundation.dll. I spent some time...

In VC++, how to access text continuously from console window and print it in a CListBox?

In VC++, how to access text continuously from console window and print it in a CListBox? Infact I have a MFC program which calls other FORTRAN exe. The output of the FORTRAN exe comes in the console window. I need to print it in a CListBox continuously. I can print it in a file and can print it at one shot. But that is not my purpose. I ...

Why do I get a "constant too large" error?

I'm new to Windows development and I'm pretty confused. When I compile this code with Visual C++ 2010, I get an error "constant too large." Why do I get this error, and how do I fix it? Thanks! int _tmain(int argc, _TCHAR* argv[]) { unsigned long long foo = 142385141589604466688ULL; return 0; } ...

Statically linking Winsock?

I'm using Winsock 1.1 in my project. I include wsock32.lib in "Additional Dependencies". I'm looking at the DLL project using depends.exe and notice that the DLL depends on wsock32.dll. How can I statically link it so that it doesn't depend on wsock32.dll? ...

Copy elision on Visual C++ 2010 Beta 2

I was reading 'Want Speed? Pass by Value' on the C++ Next blog and created the following program to get a feel for copy elision and move semantics in C++0x: http://pastebin.com/f39c826c6 However I am perplexed by one thing. Here is the output I get when compiled in release mode on Visual C++ 10.0 (Beta 2): Move assign from RVO: ...

Including common resources in multiple projects on different nesting levels (visual C++)

Hey, I have an rc file uses relative paths to locate the resource files (pictures etc.), for example IDB_LINE BITMAP "..\Shared\Res\line.bmp" BUT - a few projects are including the rc file, and these projects are found on different directory nesting levels inside the solution. This results in the fact ...

SHBrowseForFolder doesn't work for network selection in win7

Hi, I use SHBrowseForFolder in my code. It works well in XP. But I find it dose not run well in Windows 7 with the same code. When I click a network, it does nothing. But it can expand in XP. By the way, I have the permission to access the network of another computer and I try accessing the resource with explorer, it's OK! Can anyon...

MSVC: what compiler switches affect the size of structs?

I have two DLLs compiled separately, one is compiled from Visual Studio 2008 and one is a mex file compiled from matlab. Both DLLs have a header file which they include. when I take the sizeof() the struct in one DLL it returns 48, and in the other it returns 64. I've checked the /Zp switch and in both compilations it is set to /Zp8. Wha...

Deleting wchar_t pointer crashes on 64-bit build

I've got a managed c++ library that is crashing when a delete statement is encountered, but it only crashes on a 64-bit build. The code is: LPWSTR pwmsURL = NULL; pPresentationCtx->GetStringValue(L"WMS_PRESENT_ORIGINAL_REQUEST_NAME", 17, &pwmsURL, 0); String^ wmsURL = gcnew String(pwmsURL); //this delete is the problem line... delete [...

Is it possible to change display for a typedef long MyType by using autoexp.dat?

I have type which is just a typedef-ed long which one I would like to display differently in a debugger. Is it possible to do so using autoexp.dat? namespace MyNamespace { typedef long DaysSinceItAllStarted; } ...

Compiler compiling external includes

Hello, I have a little problem in my project. I have build static library(e.g. test.lib) . Included it into my binary project linker and included #include "test.h" into stdafx.h. But when binary starts to build, C error occurs on CSomeObject test: "error C2146: syntax error : missing ';' before identifier 'test'". What could be wr...

Which VC++ runtime version do I choose - static or dynamic?

I'm developing a 64-bit in-proc VC++ ATL COM server that basically just redirects all calls to an out-proc COM server. So my COM server basically does nothing. Initially it used the C++ runtime in a DLL (/MD compiler switch). I've noticed that when I deploy it on a clean 64-bit Win2k3 regsvr32 fails with an error: LoadLibrary({fileName}...

COM Basic links

Hi, folks can you provide me the tutorial link or .pdf for learning basic COM?. i do google it.. still i recommend answers of stackoverflow so please pass me.. Thanks ...