visual-c++

About API hooking

I want to check if any file,folder or window is openend from the removable media like USB and close it. ...

Why MSVC generates warning C4127 whan constant is used in "while" - C

For code, while(1) { /* ..... */ } MSVC generates the following warning. warning C4127: conditional expression is constant MSDN page for the warning suggests to use for(;;) instead of while(1). I am wondering what advantage for(;;) is giving and why it warns for the constant usage in while? What flag to use on GCC to get the ...

Malloc does not return memory, why?

I am allocating memory using malloc and freeing it after using it, but in every third operation I notice that malloc is not allocating the memory. Can anyone tell me what is happening... why malloc is not working... what should I do to allocate memory? Posting code is difficult as it involves lots and lots of files.. mostly I think tha...

Basic DirectX11 problem, code crashes as soon as I begin drawing anything to the screen. Also help with Netbeans configuration.

So, I started programming in DirectX11 today, I've had a lot experience with coding, but not specifically DirectX, so I went and look at some tutorials. All was going swell, I could initialize a window, set a background color, but then as soon as I tried to define a shader and draw an object, it just crashes on load. This code is extreme...

Global variable destructors not called, where to start?

I'm faced with the problem that my applications global variable destructors are not called. This seems to occur only if my application successfully connects to an oracle database (using OCI). I put some breakpoints in the CRT and it seems that DllMain (or __DllMainCRTStartup) is not called with DLL_PROCESS_DETACH, thus no atexit() is ca...

strange behaviour in visual c

this program hangs after taking first argument:- #include <stdio.h> #include <conio.h> void ellip(char*,...); int main(int argc,char* argv[]){ printf("a"); ellip("first argument",99,"second arg","thirdarg"); _getch(); return 0; } void ellip(char* m,...) { char com='c'; for(;;) { auto g=0; ...

Wrong menu bar when starting MFC application

My application is MFC, MDI, and in Visual Studio 2008. It has three menu bars: one to start up with, one associated with document type A, and one associated with document type B. Recently, we've been getting menu bar A showing up some of the times instead of the mainframe menu bar when we start without a document (such as double-click...

Getting "ActiveX controls could not be instantiated. Reinstall or register the controls and try again" message when viewing Dialog

I have an existing Visual C++ project using MFC that I'm running within Visual Studio 2008. The machine was just setup and installed and I have pulled the project from Source Control. The solution builds ok, but if I go into the resource file and try to pull up and view a dialog, I get the message 2 ActiveX controls could not be inst...

making com with vs

is there a way to produce com file(pure binary) from vc++ ,i dont want the exe headers, bcoz i need to develop codes for operating system... please dont suggest gnu compiler... ...

VC++ says "no overloaded function takes 7 arguments" I say YES IT DOES!

In my PDBComponent class's header file, I just created a new constructor for a grand total of two constructors: class PDBComponent { public: PDBComponent(string name,double min_current,double nom_current, double max_current, EPSCommands* command_ptr, double delay); PDBComponent(string name,double...

Error Performing Pointer Arithmetic on void * in MSVC

Error 1 error C2036: 'const void *' : unknown size file.cpp 111 I don't follow. GCC never complains about void * pointer arithmetic, even on -ansi -pedantic -Wall. What's the problem? Here's the code- struct MyStruct { const void *buf; // Pointer to buffer const void *bufpos; // Pointer to current posi...

Microsoft C++ Pre-defined Macros

Is there a cl.exe option to dump all the pre-defined Macros ( along with the defined values ). Something like gcc -dM -E - < /dev/null for gcc. ...

c++ redefine variable as constant

I have a struct: struct s { UINT_PTR B_ID; }; s d; d.B_ID=0x1; That works fine, but I want d.B_ID to be constant. I tried to use (const) but it didn't work. So after I put a value to d.B_ID, then I want make it a constant. Any ideas? EDIT ok i don't want the whole struct a constant. when i set timer and use the b.B_ID as an i...

c++ structures and constructures

ok so i nee help with this constructures struct balls { balls() { SetTimer(hWnd, balls.BALL_ID, 1, null); } int Ex; int Ey; UINT_PTR BALL_ID; }; well when i set the timer im having trouble with balls.BALL_ID. the compiler thinks that balls is structure like balls something. wel...

c++ structs and const

ok well i have structure struct balls { balls(UINT_PTR const &val) : BALL_ID(val){} int Ex; int Ey; const UINT_PTR BALL_ID; }; balls ball1(0x1); and i have a switch statement switch(wParam) { case ball1.BALL_ID: if(ball1.Ex<300) { ball1.Ex++; ...

Symbols files and debugging

Assume i have a custom service written in VC++ 6.0 and i have shipped it as part of a particular release. Unfortunately i did not take the pdb while building the binary. At a later point of time my customer reported a crash and i had to get the pdb to identify the crash cause. Will a pdb that i take now be enough to identify the point o...

Porting VC 6.0 Application to VS 2003 VC++ application

I have an application which is written in VC++ using VC 6.0 version. Now i open the project in VS2003. Does my project now have any link or relation with .Net framework as i am not using the .Net framework. Will the VC 7 compiler bring about a relationship with . Net. ...

C++ template compilation error: expected primary-expression before ‘>’ token

This code compiles and works as expected (it throws at runtime, but never mind): #include <iostream> #include <boost/property_tree/ptree.hpp> void foo(boost::property_tree::ptree &pt) { std::cout << pt.get<std::string>("path"); // <--- } int main() { boost::property_tree::ptree pt; foo(pt); return 0; } But as soon a...

c++ high memory and cpu

ok well i have a simple game that uses really high of memory and cpu. cpu goes over 44% and memory goes over 5000. here is my code Code how to fix this? EDIT memory: 5000 bytes. cpu: 44% on i5 the program get slower by the time it runs. ...

C++ double buffer and memory

Ok so my double buffer works fine but it seems that it use a lot of memory. i know that double buffer should store a copy of the ellipse I'm drawing than paint it on the screen but it after that it deletes the copy and makes new copy but it doesn't seem to delete it here is my code hdc=GetDC(hWnd); HDC memDC=CreateCompatibleDC(hdc); H...