Quantcast
Channel: Visual C forum
Viewing all 15302 articles
Browse latest View live

Windows Forms Application in Visual C++ ???!!!!

$
0
0
Hi , I want to create a Windows Form Application (NotWin32) in Visual C++ 2013. If i wouldn't see this project type inVisual Studio Express 2010 , I wouldn't search for it ! I cannot see it in My 2013 Ultimate version , why ??

Migration from VC++ to VC++/CLI ?

$
0
0

I am a VC++ developer and finds that VC++ is fast and it has everything I need. I also find that examples/forums and support in VC++ is slowly dwindling and new developers are fast moving towards c# . 

  Should I migrate to VC++/CLI for more versatility or not ? How different is VC++/CLI from regular VC++?

  Thanks in advance.




Application crash on deleting the std::set instance

$
0
0

Hi,

During fuzz testing of our application, crash is seen occasionally on set<> instance deletion. Below is the sample call stack:

099dc920 07238507 00000008 00000000 07a0a5c4 myDll!std::_Tree<std::_Tset_traits<unsigned long,std::less<unsigned long>,std::allocator<unsigned long>,0> >::_Erase+0x9 [c:\program files (x86)\microsoft visual studio 9.0\vc\include\xtree @ 1167]
099dc940 07238748 099dc964 0798b308 00000000 myDll!std::_Tree<std::_Tset_traits<unsigned long,std::less<unsigned long>,std::allocator<unsigned long>,0> >::erase+0x57 [c:\program files (x86)\microsoft visual studio 9.0\vc\include\xtree @ 937]
099dc97c 0723881c 94241a3c 07a0a5c0 07a0a5c0 myDll!std::_Tree<std::_Tset_traits<unsigned long,std::less<unsigned long>,std::allocator<unsigned long>,0> >::~_Tree<std::_Tset_traits<unsigned long,std::less<unsigned long>,std::allocator<unsigned long>,0> >+0x48 [c:\program files (x86)\microsoft visual studio 9.0\vc\include\xtree @ 540]
099dc9a0 072388bb 083ebdd8 099dca18 0722f3ea myDll!myClass::~myClass+0x5c 

099dc9ac 0722f3ea 00000001 94241984 00000000 myDll!myClass::`scalar deleting destructor'+0xb

The issue happens only during fuzz test and occasionally. 

We figured out that the memory allocated by the set<> constructor has been overwritten but not able to figure out who is corrupting the memory. [As the issue happens sporadically and there is a limitation of only 4 active breakpoints]

Our myObject object has the VMT for myClass stored at offset 0x00000000 of the instance, but the embedded set<> object inside the myClass does not, because it was not allocated/constructed with operator new, but instead, as an embedded field. 

Because our myClass destructor doesn't zap its (set<>) memory, is it possible that the allocations made inside the embedded set<> object in the myClass object body could be lost by an inappropriate call to the myClass destructor via the VMT..?

During fuzz test, our object is created and deleted in each thread. When the same memory is used for the second time, crash is seen. For Ex:

Creating myObject=82e59f0 set<>=82c8c60 by thrd=c54

Delete myObject=82e59f0 set<>=82c8c60 by thrd=c54

Creating myObject=82e59f0 set<>=84a30f8 by thrd=14c8

Delete myObject=82e59f0 set<>=84a30f8 by thrd=14c8

Could you please suggest what could be the root cause for the crash.?

As there is change in xtree between VS 9.0 and VS 10.0, is the crash on ~_Tree, a known bug in VS 9.0..?

Thanks in advance.


Text in menu not changing, even tho edited in the resource compiler

$
0
0

VS2015, MFC, MDI.

Even though I have changed the text in an item in the file menu in the IDE, when I run the program an old version of the text is there.

Is there something behind the scenes which hold some old value?

ide and runtime menu text are not the same

And if this is some sort of strange "designed behaviour" how can I stop it?


http://www.ransen.com Cad and Graphics software

an error in empty program

$
0
0


I am trying to make a pong game, from a youtube video, and the guys program is working (1st part till here:)

#include <iostream>

using namespace std;

enum eDir { STOP = 0, LEFT = 1, UPLEFT = 2,  DOWNLEFT = 3, RIGHT = 4, UPRIGHT = 5, DOWNRIGHT = 6};
class cBall
{
private:
int x, y;
int originalX, originalY;
eDir direction;
public:
cBall(int posX, int posY)
{
originalX = posX;
originalY = posY;
x = posX; y = posY;
direction = STOP;

}
void Reset()
{
x = originalX; y = originalY;
direction = STOP;

}
void changeDirection(eDir d)
{
direction = d;

}
void randomDirection()
{
direction = (eDir)((rand() % 6) + 1);
}
inline int getX() { return x;  }
inline int getY() { return y; }
inline eDir changeDirection() { return direction; }
void Move()
{
switch (direction)
{
case S"Apple-tab-span" style="white-space:pre;">break;
case "Apple-tab-span" style="white-space:pre;">x--;
break;
case RIGHT:
x++;
break;
case UP"Apple-tab-span" style="white-space:pre;">x--; y--;
break;
case DOWN"Apple-tab-span" style="white-space:pre;">x--; y++;
break;
case UPRIGHT:
x++; y--;
break;
case DOWNRIGHT:
x++; y++;
break;
default:
break;
}
}

friend ostream & operator<<(ostream & o, cBall c)
{
o << "Ball [" << c.x << "," << c.y << "][" << c.direction << "]" << endl;
return 0;  //this is the error
}
};
int main()
{
cBall c(0, 0);
cout << c << endl;
c.randomDirection();
cout << c << endl;
c.Move();
cout << c << endl;
c.randomDirection();
c.Move();
cout << c << endl;

return 0;
}

But i got an error:

'return': cannot convert from 'int' to 'std::ostream &'   Line 70

QueueUserWorkItem - WT_SET_MAX_THREADPOOL_THREADS

$
0
0

I have a windows service running in windows 7. This application adds the functions/task to be executed to a thread pool using QueueUserWorkItem. So each function/task will execute as a background thread.

The number of threads it creates is dependent on the need and it is dynamic. I want to control the number of threads it spawns.

For example, if my application needs to create 100 threads(want to execute 100 functions in background), I want to spawn only 50 threads first.. if any one the thread completed the task then spawn the next thread.

As per MSDN I  used WT_SET_MAX_THREADPOOL_THREADS to control the count of threads in thread pool.But it's not working.

Please let me know why it is not working..Do I need to do anything else.

MSDN Link:https://msdn.microsoft.com/en-us/library/windows/desktop/ms684957(v=vs.85).aspx

How do I set or change the SDK?

$
0
0

Hello,

I recently updated VS2015 to Update 2 and now I can no longer build my MFC Native C++ project. The build error I get is:

1>c:\program files (x86)\microsoft visual studio 14.0\vc\atlmfc\include\afxv_w32.h(25): fatal error C1083: Cannot open include file: 'winsdkver.h': No such file or directory

I can find this file in another SDK so I suspect that there is an SDK problem. Is is possible to have multiple Windows SDKs installed? If so, how do you specify which one you want to use?

I went into Project > Properties > Configuration Properties > General.

The two fields: Target Platform and Target Platform Version are blank. Is this how you specify which SDK to use?

Platform Toolset is set to v140_xp. Is this specifying the SDK?

What about having a line in the code that says:

#define _WIN32_WINNT0x0501

Please help me understand the system better.

thanks,

Stuart

C#

$
0
0
Write a complete C++ program that reverses the digits of a given positive integer. For example if the user enters a positive number001110, your program would print 011100.

Static Link Library and Dll from same project

$
0
0
I have a c++ assignment where I need to be able to create Both a Static Library and Dynamic Link Library from the same Visual studio 2015 Project. I know that I can configure different configurations using the configuration manager but I'm unsure what settings I need for Ether Dynamic Link Libary Static Library?

From what I understand you create two configurations in configuration manager one to generate a Static Library the other to create the Switching between different configurations enables/disables hash defines allowing you to have DLL export/DLL import or nothing for static Libary's. However, I'm not sure how to approach this.

How Word converts the PDF document with balloon text(Markup area) with revison changes information?

$
0
0

Hi All,

Can anyone knows how Microsoft Word shrinks its content when it is rendered with markup area(revision text). The input word document contains normal document page size and then markup area length. But the generated PDF document contains the page size as document page width. Microsoft Word reduces the contents size.

Thanks,

Pradeep L

Remove USB flash drive history from registry, How To?

$
0
0

Is it possible in code (C++) to remove all references to a USB flash drive from the registry, so that Windows has no record of that USB device ever being plugged into that machine? 

In code (C++) I'm using IVdsVolumeMF::DeleteAccessPath() to remove all access paths to USB flash drives.  Then I write to them, which works fine.  When the write is complete, Windows remembers that the drive letter was removed from the flash drive and will not automatically re-assign a drive letter to this device.  So Windows is remembering that this specific device was plugged in and remembers the settings.  I want to remove all references, so it is as if that flash drive had never been plugged into this machine before.  Is there a strait forward way to do this? 

Long story short; we're going to be writing to hundreds or thousands of flash drives a day on this machine (50+ at a time), and when the write is complete we need to remove all references to these devices, both so they will get the default behavior when plugged back in again, AND to keep the registry from getting bloated after doing this every day for months or years. 

Copy protect usb

$
0
0
Hello, I have video files on USB and I want to protect them from copied.


My original idea was simple, Take the serial number of the USB, Encrypt the files with the serial number, then at runtime when Windows Media Player or any other player trying to run it, decrypt it with the key - serial number of the USB.


At first I thought the players use the WinApi function ReadFile to read the file, and I wanted to do Hook the function and decrypt the data at this point - I was wrong, media player do not use this function for reading video files.
So I thought It might use some mapping functions - again failed in finding them.

I tried to build my own player, but all the players are being built at a high level Api'S and I could not locate the point where I can decrypt the data.

I'm desperate ... I'm on it for a few months, I really need help.

The goal: to protect video files stored on a USB from being copied
Way: anything that will work, I tried to encrypt and open at run time, if you know how to do one of the following:
1 decrypt data at runtime that despite thay on the disk the file encrypted media player will play the file (only when he in this particular usb)
2 decrypt data to memory variable and start video player with this variable as a file (the least good option, the system will over louded)
3 some way to make the copy-protection
I really would love to help here

How to profile compile time issues?

$
0
0

I'm looking for ideas on how to profile system resource utilization to determine the root cause of long C++ compile times .

I'm trying to figure out where it's spending all its time.  My CPU usage seems to be low 20% spiking up to 60%.  And disk usage seems to be low 5% spiking up to 30%.  I was expecting one or the other to be railed but neither seems to be maxed out.

What's the right way to determine what the bottleneck is?

Obviously I've employed many smart techniques to reduce compile time already.  But I don't see a system diagnostic that shows max utilization of some resource during a compile, so I'm a bit confused how to make accurate measurements of performance and system resource utilization.  What's the right way to observe these things?  Which system monitoring tool will show me what's being utilized while I'm compiling my C++ code with Visual Studio?

How to change ToolsVersion in VC++ 2010 Express

$
0
0
I've been using VC++ 2010 Express for projects, and just today I got a sample project file from some company and  VC++ says it want ToolsVersion=12.0, or maybe even set it  back to 4.0 (which is what 2010 apparently uses).  How exactly do I do this?  Please give me an idiot's answer because that's what I mostly am when it comes to this stuff.  Thanks - Bob

Visual Studio 2010 MSI Installer Help

$
0
0

Hello,

       Is there a way to create a dialog where a user selects a language for the installer when running the setup.exe I looked at MST transforms but that did not seem like that was something that i needed, a point in the right direction would be really helpful.

Thanks,

    Daniel


Return an array from a C++ api call to Javascipt.

$
0
0

Hi All

I recently worked on a web project to replace VBscript with JavaScript. And since JavaScript doesn't support out parameters, i need to find a way to return multiple return values of different data types from the api function written in C++.

<SCRIPT type="text/javascript">

hitLauncher = new ActiveXObject(AliUpdate.MckUpdateCtrl);

hitLauncher.GetFileVersion(nMajor, nMinor, nRelease, nBuild, isInstalled, isStarted); //C++ api call

<SCRIPT>

In the orignal VBScript code nMajor, nMinor, nRelease, nBuild, isInstalled, isStarted are all out params with different data types. I need to find a way to set these varaibles in JavaScript as well.

I am new to C++. Your advice is greatly appreciated.

How to link C# dll to C++/CLI project in VS 2013

$
0
0

I have a Visual C++ project in Visual Studio 2013 that is compiled with the /clr flag, which, as I understand it, means it has Microsoft's .Net compatibility and deviates from pure C++.

I need to add in C# libraries (System.IO.Packaging.dll and DocumentFormat.OpenXml.dll). Where in the world

Where in the VC++ project do I link these in, as there seem to be multiple places.  The one I've seen referred to most is in 

Properties->Configuration Properties->Linker->Input->Additional Dependencies

In that menu I added those two libraries, without yet adding any references to it in the C++ code.  Compiling produce the following error:

error C1308: C:\Users\Gene\Documents\WindowsPowerShell\Modules\Open-XML-SDK-vNext\DocumentFormat.OpenXml\bin\Debug\System.IO.Packaging.dll: linking assemblies is not supported

I had a simple C# project where I used these libraries and the linking was as easy as including them as a reference.  Not so in the C++.  
What's the way I can link these libraries in?  Do I need some other files too, like header files?

vs 2015 update 2 breaks build: fatal error C1083: Cannot open include file: 'winsdkver.h': No such file or directory

$
0
0

As in the title, after installed vs 2015 update 2 rtm, I cannot build any vs c++ solution:

In debug I get

fatal error C1083: Cannot open include file: 'winsdkver.h': No such file or directory

In release:

TRACKER : error TRK0005: Failed to locate: "midl.exe". The system cannot find the file specified.

So the update 2 (installed over a working update1) messed up my system.

How can we fix this?

Duplicate Error and Warning Messages displayed in Error List Window

$
0
0

Hi,

Does anyone know why I should be getting duplicate error and warning messages in the Error List window?

Below are two samples, one warning and one error that are duplicated.

Sample 1 Code

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int iUnusedVariable;


    switch (message)
...
}

Sample 1 Error List Window

SeverityCodeDescription ProjectFileLineSuppression State
WarningC4101'iUnusedVariable': unreferenced local variableShowDuplicateErrorsAndWarningse:\neil\showduplicateerrorsandwarnings\showduplicateerrorsandwarnings\showduplicateerrorsandwarnings.cpp126
WarningC4101'iUnusedVariable': unreferenced local variableShowDuplicateErrorsAndWarningse:\neil\showduplicateerrorsandwarnings\showduplicateerrorsandwarnings\showduplicateerrorsandwarnings.cpp126

Sample 2 code

#include "stdafx.h"
#include "Resource.h"

void MyFunction()
{
	undefinedVariable = IDS_APP_TITLE;


}

Here is the Error List Window

SeverityCodeDescription ProjectFileLineSuppression State
ErrorC2065'undefinedVariable': undeclared identifierShowDuplicateErrorsAndWarningse:\neil\showduplicateerrorsandwarnings\showduplicateerrorsandwarnings\undefinedvariableinthisfile.cpp6
Error (active)identifier "undefinedVariable" is undefinedShowDuplicateErrorsAndWarningse:\Neil\ShowDuplicateErrorsAndWarnings\ShowDuplicateErrorsAndWarnings\UndefinedVariableInThisFile.cpp6
ErrorC2065'undefinedVariable': undeclared identifierShowDuplicateErrorsAndWarningse:\neil\showduplicateerrorsandwarnings\showduplicateerrorsandwarnings\undefinedvariableinthisfile.cpp6


Thanks in advance.

- Neil Shore


fatal error C1012: unmatched parenthesis : missing ')'

$
0
0

I've got the error message at the title while using VC++2012 to compile the file beginning with the following snippet:

#ifndef __INCvxWorksh
#define __INCvxWorksh

#ifdef __cplusplus
extern "C" {
#endif

#if!defined(NULL)
#if defined __GNUG__
#define NULL (__null)
#else
#if !defined(__cplusplus) && 0
#define NULL ((void*)0)
#else
#define NULL (0)
#endif
#endif
#endif

#if!defined(EOF) || (EOF!=(-1))
#define EOF(-1)
#endif

#if!defined(FALSE) || (FALSE !=0)
#if!defined(FALSE)
#define FALSE0
#endif

How come?

Viewing all 15302 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>