[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now







C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.

Share tech news, updates, or what's on your mind.

Sign up to Post

I'm attempting to integrate some functionality into a C-Language DLL that I use with my PowerBuilder application in order to manipulate Active Directory users without having to buy an expensive package or do the work manually.  I basically copied the following code (found on more than one web site) and the results of the compile return errors that both the "CreateDSObject" and "Release" functions are not members of the "IDirectoryObject" or "IDispatch" structures.  Here's the code I'm using:

        HRESULT                  hr;
      IDirectoryObject              *pDirObject;
      ADSVALUE                  sAMValue;
      ADSVALUE                  uPNValue;
      ADSVALUE                  classValue;
      LPDISPATCH                  pDisp;
      REFIID                        IID_IDirectoryObject;
      ADS_ATTR_INFO  attrInfo[] =
            { L"objectClass",            ADS_ATTR_UPDATE, ADSTYPE_CASE_IGNORE_STRING, &classValue,      1 },
            { L"sAMAccountName",      ADS_ATTR_UPDATE, ADSTYPE_CASE_IGNORE_STRING, &sAMValue,            1 },
            { L"userPrincipalName", ADS_ATTR_UPDATE, ADSTYPE_CASE_IGNORE_STRING, &uPNValue,            1 },
      DWORD dwAttrs = sizeof(attrInfo)/sizeof(ADS_ATTR_INFO);
      classValue.dwType                        =      ADSTYPE_CASE_IGNORE_STRING;
      classValue.CaseIgnoreString            =      L"user";
      sAMValue.dwType                              =      ADSTYPE_CASE_IGNORE_STRING;
      sAMValue.CaseIgnoreString            =      L"browvick";
      uPNValue.dwType                              =      ADSTYPE_CASE_IGNORE_STRING;
      uPNValue.CaseIgnoreString            =      L"Vicky_Brown@gmail.com";
      hr = ADsGetObject(      L"LDAP://DC=domainname,DC=com",
                                    (void**) …
Hello Experts,

I have a C++ program which allocates named shared memory of a structure. I need to be able to read that same structure from a c# program. Here is my c# code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace WindowsFormsApplication1
    public partial class Form1 : Form
        [StructLayout(LayoutKind.Sequential, Size = 218)]
        public struct TEST_STRUCT
            public long tnum;                     //size = 8
            public long pass_count;               //size = 8
            public long fail_count;               //size = 8
            public long try_count;                //size = 8
            public double sum_result;               //size = 8
            public double sumsq_result;             //size = 8
            public double min;                      //size = 8
            public double max;                      //size = 8
            public long histogram;                //size = 8*40
            public bool tested;                   //size = 4
            public bool passed;                   //size = 4 
            public double last_result;              //size = 8

Open in new window

Hi, dear experts:

I have a stupid question here, I used MFC for a long time, I still don't know why should I can the base class handler even when I provide the function to handle the message, here is an example:

class CMyDialog : CDialog

void CMyDialog:OnLButtonUp(UINT nFlags, CPoint point)
    CDialogBox::OnLButtonUp(nFlags, point);

In fact when Class Wizard generate the message handler, it added base function call CDialogBox::OnLButtonUp(nFlags, point);

Here now here is my question, why do we need to call this function? what if I do not call this function?

Thanks for your help.
my code works just fine and I got no error message.
But how can I check the the delete was done? Like a if - else routine

//%%%%%%%%%%%%%%%%%%%%%%%%%% Löschung %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	//SQL Server
	m_strConnection = _T("Driver={SQL Server}; Server=DSERVER; Database=OMSDATEN;Uid=;Pwd;");
	//Initialize the Recordset and binding pointers
	m_ptrRs = NULL;   
       m_piAdoRecordBinding = NULL;   

	//Initialize the COM environment
		//Create the recordset object

//======================================= Delete ==============================================================
   sql.Format("DELETE LogBuch FROM LogBuch WHERE Zeitstempel>='%s' AND Zeitstempel<='%s'",str_loeschen_von,str_loeschen_bis);
      _bstr_t bstrQuery(sql);
		//Open the recordset object Tabelle 
 m_ptrRs->Open(_variant_t(bstrQuery),(LPCTSTR)m_strConnection, adOpenDynamic, adLockOptimistic, adCmdUnknown);

		//Get a pointer to the record-binding interface Coils
		if(FAILED(m_ptrRs->QueryInterface(__uuidof(IADORecordBinding),(LPVOID *)&m_piAdoRecordBinding)))     _com_issue_error(E_NOINTERFACE);
		//Bind the record class to the recordset

Open in new window

I am trying to set permission on an application as read/execute only, I can achieve this by using c++ windows SetSecurityDescriptorDacl() function.

But after that admin can change it by right clicking on a file

    properties->security->advanced->Change Permission

But somehow antivirus prevents these charges on their application ..
//************************** tracks indexs*******************
each track saved in sd card has index , so to play track number we will using it's index 
for example to play track number 1 we will using "00003"  index which will send to play track function 
all the same for the rest of all tracks 
char buffer15[6]={"00001"};  // track 15 index 
char buffer16[6]={"00002"};  // track 16 index
char buffer1[6]={"00003"};   // track 1 index
char buffer2[6]={"00004"};   // track 2 index
char buffer3[6]={"00005"};   // track 3 index
char buffer4[6]={"00006"};   // track 4 index
char buffer5[6]={"00007"};   // track 5 index
char buffer6[6]={"00008"};   // track 6 index
char buffer7[6]={"00009"};   // track 7 index
char buffer8[6]={"00010"};   // track 8 index
char buffer9[6]={"00011"};   // track 9 index
char buffer10[6]={"00012"};  // track 10 index
char buffer14[6]={"00013"};  // track 14 index


Open in new window

How can I access these mp3files via filename not index
We will install a visual studio version, probably 2015 or 2017 so that we can be ready for the present someday in the future. But for now we have to deliver our source code to the customer who only knows about Iso c++03.

This means that if a developer inserts some newer c++11/14 constructs into our code base, then I want the computer to issue fatal errors forcing the developer to have to conform to c++03.

I found this link that does not appear to go back far enough in time.

If you have an answer, please provide a relevant link that supports your response so that I can show my manager. Thanks.

Using Windows 10.
I use : to create  a new HWND

But requires the strike code for the window HWND chance his size

bool HWND (chance size)
x = windowX
y= windowY


BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
   HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,

   if (!hWnd)
      return FALSE;

   ShowWindow(hWnd, nCmdShow);

   return TRUE;

Open in new window

i use,
hwndEdit = CreateWindowExW(WS_EX_CLIENTEDGE, TEXT("Edit"), NULL, WS_CHILD, 10, 10, 200, 150, hWnd, (HMENU) NULL,NULL,NULL );
ShowWindow(hwndEdit, SW_SHOW);

Open in new window

to add a text box of one line , now i want to add a multi line field.

after solving some ugly other problems with make, I run now into the problem about the CXXFLAGS. It looks like make do not use this FLAGS.  My makefile looks like:

CXX = g++
CXXFLAGS = -g -std=c++11 -Wall -pedantic

root := /usr/share/doc/xsd/examples

include $(root)/build/cxx/rules.make
include $(root)/build/xsd/tree-rules.make

$(CXX) $(CXXFLAGS) -c 05_bxf2.cxx

	$(CXX) $(CXXFLAGS) -c XSDValidator.cpp

	$(CXX) $(LDFLAGS) -o XSDValidator.o 05_bxf2.o

	rm -f *.o

Open in new window

The repsone I got in termional after calling make

g++ -W -Wall -O3 -c 05_bxf2.cxx

Open in new window

This is not what I added to the makefile. Any idea why make do not use the Flags?

When i, wane add a new EDIT child window which the user can type text from the keyboard.
a normal text box works, but when I challenge  CreateWindowExW( EDIT ..)

and  BUILD and run the program from my compute noting happens.

Do i miss the paint code or something.

//  Add a new TEXT imput box
//CreateWindow(TEXT("EDIT"),TEXT ("VALEU"), WS_VISIBLE | WS_CHILD | WS_BORDER ,10,10 ,200,25,hWnd, (HMENU) NULL,NULL,NULL );

// Add a new TEXT edit window

CreateWindowExW(WS_EX_CLIENTEDGE, TEXT("Edit"), NULL, WS_CHILD, 10, 10, 200, 25, hWnd, (HMENU) NULL,NULL,NULL );

Open in new window

I have really problems to understand makefile and its rules.
I created a makefile that works perfect. Now I want to remove objects before compile but it do not work with rm -f *.o
I get always the message "Missing seperator. stop"

# Build
# /opt/rh/devtoolset-4/root/user/bin/
    rm -f *.o

root := /usr/share/doc/xsd/examples

include $(root)/build/cxx/rules.make
include $(root)/build/xsd/tree-rules.make

XSDValidator: XSDValidator.o 05_bxf2.o
05_bxf2.o: 05_bxf2.cxx 05_bxf2.hxx
XSDValidator.o: XSDValidator.cpp 05_bxf2.hxx

Open in new window

Any Idea what I do wrong? Without "clean: rm-f *.o" it works well. I also tried to use a tab before "rm"
But nothing helps. It looks like "rm" do not work in makefile?
Hello All, I need help. Badly!

We have a Mercurial repo that keeps out source code for the last year. Yesterday, and error popped up when compiling one of the solutions (see compile_error.jpg). I then ran other projects from that same solution that did compile, and I get the runtime error seen in the file runtime_error.jpg. I then went back to a repo from September 2016, and I get the exact same compile time and runtime errors.

I have tried this on 4 systems. All four systems are Windows Pro 64 bit. I'm using VS2013 C++.

I don't suspect the code itself nor the repository. I'm thinking a Windows 7 update, or a VS update, or ???

Please help. I need ideas.

Thanks, Brian
I compiled my first app on Linux and I get an error:
./XSDValidator: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./XSDValidator)

Open in new window

I made a check:
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX_3.4.1

Open in new window

And yes, it is not present. But how this error comes? I use gcc 5.1.0 is this the problem?

The software I compile use xerces-c as depency but this was installed with yum on my machine so I think it will not install things that link against a wrong libstdc++, right?

How to avoid this linking to an wrong libstdc++ ?
Hi, i wish if everyone is having a good day.
However i have an problem in mysql i would like to get the count of ids column in my table and plus 1 to the number how ever when i do like that it types +1 as string for example the result of counting was 3 it will add 3 to 1 like this 31 not 3+1=4 so i don't know how to solve this here's my code :

		String^ constring = L"datasource=...;port=...;username=...;password=..."; // Giving informations to the server
		MySqlConnection^ conDataBase = gcnew MySqlConnection(constring);
		MySqlCommand ^GetCount = gcnew MySqlCommand("Select Count(ID) from newdatabase.my_table;", conDataBase);
		MySqlDataReader^ myReader;
		MySqlCommand ^cmdDataBase;

		try {
			myReader = GetCount->ExecuteReader();
			while (myReader->Read()) {
				int Got = myReader->GetInt32(0);
				cmdDataBase = gcnew MySqlCommand("Insert into newdatabase.my_table (ID) Values ('" + Got+1 + "');", conDataBase);//queries
			myReader = cmdDataBase->ExecuteReader();
		catch (Exception ^Ex) {

Open in new window

Hi i was having some problems in finding the screen width and height how ever i am working on an project and i finally found

Open in new window

but every time i use this function in CLR i am getting this problem :
1>Width.obj : error LNK2028: unresolved token (0A00002E) "extern "C" int __stdcall GetSystemMetrics(int)" (?GetSystemMetrics@@$$J14YGHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
1>Width.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall GetSystemMetrics(int)" (?GetSystemMetrics@@$$J14YGHH@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)

Open in new window

Isn't it supported in Clr ? if yes what i can use instead.
Hello everyone.

I've seen that what I'm trying to do which is monitoring the file IO require the use of Window File System Filter driver and I've also looked into it but was a bit hard to understands especially as I'm not a C++ developer. What I want to achieve is to be able to trap file copy, creation, as well as file sources and destinations, lets say I'm copying a file within my computer I want to get the source path of the file as well as destination path of the file and also the file name as well and if possible with the application that is sending the file.

I saw that this can also inform you if there is file access(opening of file, reading of file) this is very much important to me to also get it if possible while the request of file open is created. I wan to trap this and if the file is one of my file then I want to first work on the requested file first (decrypt).

Thank you.
Hi, Iam new to Linux and I have some problems compiling C++ code there.
A default "Hello World" software works fine. Compile and run well.

But now I want to add another code for XML and it looks like that I do something wrong in my makefile.

I use in my code:
# Build
root := /usr/share/doc/xsd/exmaples

include $(root)/build/cxx/rules.make
include $(root)/build/xsd/tree-rules.make

Open in new window

Bu the make/compiler give me the message that rules.make and other files cannot be found.
Can anyone help and explain what I did wrong?
We just moved from WinINET to WinHTTP. The latter does not have an equivalent InternetCanonicalizeUrl function.

The WinHTTP docs say that WinHTTPOpenRequest does this automatically but there is nothing there that specifically addresses this.

According to this reference you can use WinHTTPCreateURL which uses a URL_COMPONENTS structure to define the various URL parts. In the latter the lpszExtraInfo property is where you put the ?param=xyz& ... part.

Here is my problem - one of the parameters in the paramter string needs to be canonicalized as it could contain non-URL friendly characters (Example &).

With the WinINET version we used InternetCanonicalizeUrl on the specific URL parts which were then appended to the URL string.

If we have a URL now that looks like this
mydomain.com?param='Name & Surname','Description'

Open in new window

And we pass that to WinHTTPOpenRequest - it does not know that the & in Name & Surname is data and not a parameter separator.

How do we canonicalize individual parameters in the URL with WinHTTP
Hi Experts,

         I have a alpha numeric text of length (4096 to 8192)Bytes. I need a compression algorithm to compress and decompress text length upto (128 to 256)Bytes.

I have already tried some compression methods but not able to compress text upto (128 to 256)Bytes .
(eg: Zip.)

To perform this job we need only compression method not hash value.

Thanks In advance
language : c++
(tools : visual studio , acrobat reader)
thanks a lot
I am writing a REST client application using Embarcadero C++ builder Xe10.1 Berlin.
I need to have the REST server IP address configurable.
I have initially set the TRESTClient component BaseURL property to a known server IP address in the IDE. The BaseURL property value is and the application works just fine.
If I add code to change the BaseURL property however, the application doesn't respond and times out ?
Even if I use the value that works when set in the IDE, after the following code is run the application stops working ?

RESTClient1->BaseURL = u"";

Open in new window

Any ideas please ?
	 sql.Format("SELECT * INTO Sicherung_Thomas.dbo.LogBuch_%s FROM OMSDaten.dbo.LogBuch WHERE Zeitstempel>='%s' AND Zeitstempel<='%s'ORDER BY Zeitstempel ASC",str_tmp,str_loeschen_von,str_loeschen_bis);
	 _bstr_t bstrQuery(sql);
  	//Open the recordset object Tabelle 
    m_ptrRs->Open(_variant_t(bstrQuery),(LPCTSTR)m_strConnection, adOpenDynamic, adLockOptimistic, adCmdUnknown);
    //Get a pointer to the record-binding interface Coils
	if(FAILED(m_ptrRs->QueryInterface(__uuidof(IADORecordBinding),(LPVOID *)&m_piAdoRecordBinding)))     _com_issue_error(E_NOINTERFACE);

	   //---------- Any erros? -------------
    	catch (_com_error &e)
			//Display the error
        	GenerateError(e.Error(), e.Description());


	// Do we have a valid pointer to the record binding?
	if(m_piAdoRecordBinding) m_piAdoRecordBinding->Release();       
	//Set the recordset pointer to NULL
	m_ptrRs = NULL;     
	//Shut down the COM environment

void  CDatenbank_Anzeigen_Loeschen_Dialog::GenerateError(HRESULT hr, PWSTR pwszDescription)
	CString strError;
	//Format and display Error Message

Open in new window

Hi :)
This is my first post here and i hope to get an help :)
Anyway let's start with asking my question
my problem was that i only get 1 section name when using getprivateprofilesectionnames function
so i have searched a lot for an solution and i already found an solution but i don't actually understand how that works so could some one explain what's happening in the loop please ?

int main()
	char buffer[4096];
	GetPrivateProfileSectionNames(buffer, 4096, ".//SectionO.ini");

	char* Get = (char*)buffer;
	size_t length = 0;
	int nCnt = 0;
	while (*Get)
		length = strlen(Get);
		cout << nCnt << Get << endl;
		Get += length;
    return 0;

Open in new window

^ this is the code i have found can some one please explain what's happening in the loop ?
thanks guys.
MFC CComboBox won't display wide characters.
I'm using VS 2008, UNICODE is defined in the build and all of the prompts and other strings in the app are coming out fine.
The first try I just added the strings like any combobox and the display and dropdown showed a black line for each
character like the font was wrong.

I tried to SetFont to no avail.

I went to an owner-drawn combo box with no change.
The string shows correctly in the debugger (both in the watch and in the hover box).
the string is "Активна" and, copied from the debugger window,  shows up fine in WordPad.

In DrawItem I did:

      CString fontName;
      CDC dc;

//fontName is "MS Sans Serif" which is is expected and what I am using in the rest of my app and is reported to support Cyrillic.
//The rest is :

      CString thisString;
      GetLBText(lpDrawItemStruct->itemID, thisString);      

//note that at this point,  thisString shows to have the correct string in the debugger

      dc.TextOut(rc.left+iOffsetX, rc.top + iPosY,thisString);      

And I get " ||||||| "  in the combo box (both edit box and dropdown).

      dc.TextOut(rc.left+iOffsetX, rc.top + iPosY,L"TESTSTRING");
works fine.

Any ideas would be helpful...I've been working this way too long.






C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.