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

VS 2013 Update 5 - New ATL project fails to compile with error C2732

$
0
0

After creating a new project using the Visual C++ ATL Project template, building it fails as follows:

MyApp.cpp(26): error C2732: linkage specification contradicts earlier specification for 'DllGetClassObject'
  MyApp.cpp(25) : see declaration of 'DllGetClassObject'

This is the code frag:

// Returns a class factory to create an object of the requested type.
STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv)
{
   return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}

The same project type on a colleagues machine builds perfectly without error. A project created on his machine, fails to build on mine. I've also tried uninstalling VS 2013 and re-installing from the VS 2013 Update 5 ISO, repairing the SDK, but the issue persists.

Is there a component on the machine for ATL which could cause the compiler to fail?

Any pointers would be appreciated as my only option is to completely rebuild my dev machine. :-/

Thanks.



enum in IDL

$
0
0

Hello folks,

I've defined an enum in my IDL file:

typedefenum


{

PROP_PROPSET = 0,

PROP_PROPGET = 1,

PROP_PROPNOTIFY = 2

} PROPREQOPERATION ;

Unfortunately, this enum does not appear in .tlh file.

What can be the reason?

is it going to be 2?

$
0
0

q = 1

q = q <<1;

Is  the q going to be 2?

How to change Local Group Policy

$
0
0

Hi, 
I write a litle C++ App for installation purpose. Here I want to add a user to the "Log On As Batch Job" policy under "User Rights Assignment" like I can do with gpedit.msc.
I use the IGroupPolicyObject interace, but don't know if I should call OpenDSGPO () or OpenLocalMachineGPO ().

With OpenDSGPO I used "Local Computer Policy\\Computer Configuration\\Windows Settings\\Security Settings\\Local Policies\\User Rights Assignment"
as path variable, but always get an error.

OpenLocalMachineGPO (GPO_OPEN_LOAD_REGISTRY | GPO_OPEN_READ_ONLY) works, but the returned hkey has no subkeys. RegQueryInfoKey () returns 0 for lpcSubKeys and every call to RegOpenKey () fails with error 2.

What am I doing wrong?

Thanks Frank

Background color of window

$
0
0

I created a window.(my program is using Win32 API, not MFC)

Current background color is default grey color but I want to change it to other color with RGB value.

How could I do this?


Int with char ?

$
0
0

^ (inv & (1 << ((bi+5) & 7))?1:0)

for(bi = 0; bi < 8; bi++) {
            // based on transformation 5.1
            // could also be done with a loop based on the matrix
            aes_sbox[i] |= ((inv & (1<<bi)?1:0)
                        ^ (inv & (1 << ((bi+4) & 7))?1:0)
                        ^ (inv & (1 << ((bi+5) & 7))?1:0)
                        ^ (inv & (1 << ((bi+6) & 7))?1:0)
                        ^ (inv & (1 << ((bi+7) & 7))?1:0)
                        ^ AES_SBOX_CC & (1 << bi)?1:0)
            ) << bi;

bi is char variable. So how does it work ? 

Thanks 


Are there multiple libraries for FormatMessageA?

$
0
0

This MSDN web page:  Looking Up Text for Error Code Numbers tells us that we should load netmsg.dll to get an accurate translation for a series of error codes.  It does not state if there are, or are not, any additional libraries that we might need to use for other error codes.

Are there any additional such libraries?  How might we (honorable coders that strive to understand the errors we solicit) verify that answer for ourselves?


~jag77 We need to know what a dragon is before we study its anatomy. (Bryan Kelly, 2010)

Cannot get the c++ ide

$
0
0
I installed Microsoft Visual Studio Community 2015 in windows10 laptop.Before installation I selected the option for Visual c++ by custom selection.But after installation I dont have c++ template but other languages like c#,f+,etc are present.I cant access c++ ide.Is it possible to install visual c++ from this studio.If yes please tell the steps to do so.

function for area of triangle with given sides.

$
0
0

#include<iostream> #include<cmath> void triangleArea(float a, float b, float c) { float s; float area; s = (a+b+c)/2.0; area = sqrt(s(s-a)(s-b)(s-c)); //shows error of must have pointer-to- function type cout<<area; } int main() { float side1, side2, side3; cout<<"Enter the side of tirangle: "; cin>> side1; side2; side3; triangleArea(side1, side2, side3); return 0;

}


How to receive data from the serial port?

$
0
0

Hello friends:

WithVisualStudioCommunity 2015I created aVisualC++CLRform.I added aRichTextBoxandSERIALPORT.I have the versionVisualC# andVisualBasic2015made thisinterface.I want to dothe same exampleforVisualC++CLR.

You candownload theproject hereto betteryou seethe codes.

Visual C#:

Download

Visual Basic 2015:

Download

Can somebody help me?
At least the partof receiving datafrom the serial portand display it inthe RichTextBox.

Best regards.


http://electronica-pic.blogspot.com


Open-Sauce for Halo: Custom Edition

$
0
0

I am trying to get some help with a project that is a clone of Kornner Studios' repository on BitB/ucket.

I as wondering, if anyone wanted to help me implement new features into Halo: Custom Edition via OpenSauce, like some features in Phasor, which is another end-plug-in for CE as a .dll file, I think?

I am willing to donate money for help, but ask for a reasonable pay amount, as this project is a non-for-proffit project.

I will not be paying for goods, but donating is acceptable.

I just want to get like-minded and like-interested people together to help out the halo Cmmunty.

E-Mail me at: admiral1@gmail.com

Skype me at: guardian2433

Any and all help is appreciated.

Thanks.

Sincerely,

~David

Read from com port

$
0
0

I have to read data from rfid reader which is connected on my pc via com port (usb -> com port connection driver works)

But i can build the code listed below but i can't get a connection.

 

HANDLE hPort;

hPort = CreateFile (

"COM7", // Pointer to the name of the port

GENERIC_READ | GENERIC_WRITE,

// Access (read-write) mode

0,

// Share mode

NULL,

// Pointer to the security attribute

OPEN_EXISTING,

// How to open the serial port

0,

// Port attributes

NULL);

// Handle to port with attribute

// to copy

DCB PortDCB;

// Initialize the DCBlength member.

PortDCB.DCBlength =

sizeof (DCB);

// Get the default port setting information.

GetCommState (hPort, &PortDCB);

// Change the DCB structure settings.

PortDCB.BaudRate = 4800;

// Current baud

PortDCB.fBinary = TRUE;

// Binary mode; no EOF check

PortDCB.fParity = FALSE;

// Enable parity checking

PortDCB.fOutxCtsFlow = FALSE;

// No CTS output flow control

PortDCB.fOutxDsrFlow = FALSE;

// No DSR output flow control

PortDCB.fDtrControl = DTR_CONTROL_ENABLE;

// DTR flow control type

PortDCB.fDsrSensitivity = FALSE;

// DSR sensitivity

PortDCB.fTXContinueOnXoff = TRUE;

// XOFF continues Tx

PortDCB.fOutX = FALSE;

// No XON/XOFF out flow control

PortDCB.fInX = FALSE;

// No XON/XOFF in flow control

PortDCB.fErrorChar = FALSE;

// Disable error replacement

PortDCB.fNull = FALSE;

// Disable null stripping

PortDCB.fRtsControl = RTS_CONTROL_ENABLE;

// RTS flow control

PortDCB.fAbortOnError = FALSE;

// Do not abort reads/writes on

// error

PortDCB.ByteSize = 8;

// Number of bits/byte, 4-8

PortDCB.Parity = NOPARITY;

// 0-4=no,odd,even,mark,space

PortDCB.StopBits = ONESTOPBIT;

// 0,1,2 = 1, 1.5, 2

// Configure the port according to the specifications of the DCB

// structure.

if (!SetCommState (hPort, &PortDCB))

{

// Could not configure the serial port.

//dwError = GetLastError ();

MessageBox (

"Unable to configure the serial port");

}

BYTE Byte;

DWORD dwBytesTransferred;

ReadFile (hPort,

// Port handle

&Byte,

// Pointer to data to read

1,

// Number of bytes to read

&dwBytesTransferred,

// Pointer to number of bytes

// read

NULL);

 

And does someone perhaps know how to write the data read from the com port into a text-file?

 

thanks in advance

Chain of Responsibility pattern

$
0
0

I have been looking into design pattern especially the Chain of Responsibility pattern(from Design Patterns Explained Simply ebook). The explanation states that " If the
"current" object is not available or sufficient, then it delegates to the
base class, which delegates to the "next" object, and the circle of life
continues.".

But some of the examples online (eg:http://www.coderslexicon.com/chain-of-responsibility-pattern-c/) does not  delegates the request to base class, but passes the request to the next in the list. Is it truly a requirement to pass a request to base class if not handled by the current object so that the base class then route the request to next?

Create a COM wrapper

$
0
0

Greetings, I need to create a COM wrapper in VS 2012.  I'm new to VS, so be kind.  Anyway I have 3 files, xx.h, xx.lib and xx.dll that I need to create a COM wrapper for general Windows usage. Here is the issue from the "owner" of the dll.

xx.dll is not programmed as a  (COM) server object (COM library) and therefore it does not support DllRegisterServer.

Any help would be appreciated.

Thanks Dennis

Issues in executing VC++6.0 migrated project in VS2013 C++

$
0
0

Hi All,

I have migrated a simple vc++ 6.0 MFC application in VS2013. But while executing it is crashing with Event viewer showing issue related to different dll's. Event viewer snapshot is as below:

Faulting application name: SortPatternXMLGenerator.exe, version: 520.3.7.10, time stamp: 0x56c62d0e
Faulting module name: vrfcore.dll, version: 6.3.9600.17298, time stamp: 0x544af0e0
Exception code: 0x80000003
Fault offset: 0x000035d1
Faulting process id: 0x1c04
Faulting application start time: 0x01d16a8f34b816b9
Faulting application path: C:\Users\abhatt\Desktop\SortPatternGenerator_US\SortPatternGenerator_US\Debug\SortPatternXMLGenerator.exe
Faulting module path: C:\Windows\SYSTEM32\vrfcore.dll
Report Id: 747bb237-d682-11e5-a5fb-f01faf2ecca2

 

Is anything specific is required in the Dev environment of VS2013 to run legacy VC++ 6.0 migrated application?


How to enable to horizonal scroll bar for listbox?

$
0
0

Hi,

I am using Visual C++ 2008. I just enable the "Horizontal Scroll" property of my Listbox Control to True. But if I add a string longer than the width of the listbox. The horizontal scrollbar will not appear. Why?

Thanks

Problems accessing CPU Counter data with C++ program

$
0
0

Hello

I'm using Visual Studio Enterprise 2015 and C++. I believe I should be able to access CPU Counter data as described here https://msdn.microsoft.com/en-us/library/bb385751.aspx

However all CPU counter values are zero for execution within my code.

For some counters (e.g. Last Level Cache Misses) I do get non-zero inclusive values, but zero exclusive values for my functions.

And for other counters (e.g. FLOPS) I get zero everywhere.

I’m not particularly familiar with VS so I could be doing something stupid. Thanks in advance for any help.

Best wishes.


error LNK2019 while using templates

$
0
0

I am trying to change my program to work with templates. It works fine without templates but generates error 2019 when I use the templates.

//---------------------Vector.h code--------------------------------------

#include<iostream>
template <typename T>
class vectorClass
{
private:
int n; //# elements in vector
int capacity; //size of <g class="gr_ gr_31 gr-alert gr_gramm undefined Grammar only-ins doubleReplace replaceWithoutSep" data-gr-id="31" id="31"><g class="gr_ gr_33 gr-alert gr_spell undefined ContextualSpelling ins-del multiReplace" data-gr-id="33" id="33">lowlevel</g></g> array
T* <g class="gr_ gr_34 gr-alert gr_spell undefined ContextualSpelling ins-del multiReplace" data-gr-id="34" id="34">elem</g>;

public:
vectorClass() :capacity(10), n(0)
{
elem = new T[capacity];
}

void pushback(T val);
void increase_capacity(T sz);
void print();
void popback();
void insert_atposition_value(int pos, T val);

T& operator[](int pos);

//const int& operator[](int pos)const;

};

//-----------------Vector.cpp------------------------------------------

#include "Vector.h"

template <typename T> void vectorClass<T>::pushback(T val)
{
if (n >= capacity)
increase_capacity(2 * capacity);

elem[n] = val;
n++;
}

template <typename T> void vectorClass<T>::increase_capacity(T sz)
{
if (sz <= capacity)
return;
int *p = new T[sz];
for (int i = 0; i < n; i++)
p[i] = elem[i];
capacity = sz;
delete[] elem;

elem = p;
}

template <typename T> void vectorClass<T>::print()
{
for (int i = 0; i < n; i++)
std::cout << elem[i];
}

template <typename T> void vectorClass<T>::popback()
{
elem[n - 1] = 0;
n--;
}

template <typename T>void vectorClass<T>::insert_atposition_value( int pos, T val)
{
if (pos > capacity)
std::cout << "Out of Bounds \n";
pushback(0);

for (int j = n - 1; j >= pos; --j)
elem[j] = elem[j - 1];

elem[pos] = val;

}

template <typename T> T & vectorClass<T>::operator[](int pos)
{
// TODO: insert return statement here
return elem[pos];
}

//const int & vector::operator[](int pos) const
//{
//// TODO: insert return statement here
//return elem[pos];
//}




How can I send the console output to a window inside Visual Studio 2015?

$
0
0

Hi,

i am creating a console C++ native executable and would like to see the output (such as that from cout << "asdfas") in a window inside the VS IDE ... I know I can see the output in the console standalone window but it is not practical as to screen real-estate ...

Thanks,

Juan


Juan Dent

How can I find if an iterator is invalid?

$
0
0

Hi,

I am using std::vectors and lists and at some point I want to verify if an iterator is usable... How can I find this out?

Thanks

Juan


Juan Dent

Viewing all 15302 articles
Browse latest View live


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