C++

57K

Solutions

24K

Contributors

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 consume a web services client.
I have a certificate with password. I can retreive the certificate from my store and i can use it in InternetSetOption.
But I don't know how to send the password with the certicate.

Thanks for your hep.

Here is an example:

      LPWSTR pswzFirstCert = L"xxxxx";// Subject of the first certificate.
      LPWSTR pPassword = L"yyyyyy";// Spassword
      HCERTSTORE hSystemStore; // The system store handle
      PCCERT_CONTEXT pDesiredCert = NULL;

      hSystemStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER,L"MY");
      if(hSystemStore == NULL)
      {
            ShowMessage("Not Opened the MY system store.");
            return;
      }

// Get a certificate that has the string "Full Test Cert" in its subject.
      if(pDesiredCert)
            CertFreeCertificateContext(pDesiredCert);

      pDesiredCert=CertFindCertificateInStore(hSystemStore, MY_ENCODING_TYPE, 0, CERT_FIND_SUBJECT_STR, pswzFirstCert, NULL);
      if(pDesiredCert == NULL)
      {
            ShowMessage("The certificate was not found.");
            return;
      }

      if(hSystemStore)
            CertCloseStore(hSystemStore, CERT_CLOSE_STORE_CHECK_FLAG);

      if( InternetSetOption (Data, INTERNET_OPTION_CLIENT_CERT_CONTEXT, (LPVOID)pDesiredCert, sizeof (CERT_CONTEXT) ) == FALSE )
            ShowMessage("InternetSetOption failed with error.");

      if( InternetSetOption (Data, INTERNET_OPTION_PASSWORD, (LPVOID)pPassword, sizeof (pPassword) ) == FALSE )
            ShowMessage("InternetSetOption failed with error.");

      if(pDesiredCert)
            …
0
I am writing a software removal program, and want to uninstall a context menu driver. Just unregistering the driver while Windows File Explorer is open causes a Windows error "Program has stopped working" when trying to unregister the dll. Closing file explorer first and then running the program works fine.

Here is the unregister code I am using now:

HINSTANCE hLib = LoadLibraryW(szDllPath);

    if (hLib == NULL)
    {
		DWORD dwErrorCode = GetLastError();
		szError.Format(_T("\nWindows could not load library %s due to %s"),szDllName,getLastWinError(dwErrorCode));
		return false;            
    }

    typedef HRESULT (CALLBACK *HCRET)(void);
    HCRET lpfnDllRegisterServer;

    // Find the entry point
    lpfnDllRegisterServer = (HCRET)GetProcAddress(hLib, "DllUnregisterServer");



    if (lpfnDllRegisterServer == NULL)
    {
		szError = NEWLINE;
		szError = ERR_PROCEDURE_ADDRESS;
		return false;            
    }

    // Call the function by function pointer..
    if (FAILED((*lpfnDllRegisterServer)()))            
    {   
		szError.Format(_T("\nWindows could not unregister context menu driver %s!"),szDllName);
		return false;            
    }

    FreeLibrary(hLib);

Open in new window


What is the best way to go about this to avoid this Windows error?
0
VS2010 has a feature to "Restore Window Layout" to relay out all mainframe, menu, toolbars, and dockPanes, without restarting. How do I have my VS2010 wizard-generated MFC MDI app does this programmatically? Thanks.
0
I want to invoke login() method written in java.this login method requires one input parameter of type Consumer. Please find signature below.

 public void login(Consumer<String> consumerObj)
{
     ------------
}
In JNI implementation(C++ side) I need consumer like below.

env->CallVoidMethod(loginMethodClassID, loginMethodID,consumerObj);
I am not able to create consumerObj.

For your reference,sharing my java code snippet. In my Java Test class for invoking this same login method I do following.

Consumer<String> consumerObj= url ->
{
   webBrowser = new WebBrowser(url);
   webBrowser.start();
};
Application.login(consumerObj);
I know how to invoke login method but I need help on how i should create that consumerObj object.

Your help will be highly appreciated
0
I have recently learned C++ and C#. That is, I have taken courses to understand the basics of them and now want to start using them for professional work. I have said I want to take on projects that push me to learn a lot more about these vast programming languages. I have a hardware device name Griffin PowerMate. It is a USB knob/wheel that can be helpful controlling a computer. For some reason, it does not have great support on Window 7, 10. It does have a driver for Window XP and Vista. I cannot get this device to do what I want in Windows 10. However, on a Mac computer, the driver is up to date and does everything I want. So, to me this proves what I want on the Windows side is possible. Is it likely to think that without an SDK from the company I could use C++ or even C# to create a driver for this device?
0
Reading and Writing CSV Files in MFC code

Files has to open in OpenOffice for the first Data. without closing the OpenOffice  ,In background  ,program s running and
datas has to saved in the CSV files. close the file and reopened the file .new data s has to updated.But only one data thats is also first data only in CSV file.(only in OpenOffice ,datas are not saved  while processing file should in open then  close the file  and reopened the same file,no datas updated )

code was working in CSV FIle Viewer and Notepad++ while opened while processing ,closed and reopened the same file, data are updated )
Plz help
0
Hello everybody!
I`m looking for a good and EASY library that works with sending and getting a .wav file voice message, can you please share your experience with me which library to choose as there are plenty of them out there
Thank you in advance!
0
Hi!!!
I was going to send a struct from a client to a server using boost::asio::async_write_some, in this case boost::serialization and boost::property_tree come to help,
//boost::serialization
struct blank
{
    int m_id;
    std::string m_message;

    template<typename archive>
    void serialize(archive& ar, const short version)
    {
        ar & m_id;
        ar & m_message;
    }
};

blank info;

info.m_id = 1;
info.m_name = "Rasul";

std::stringstream ss;
boost::archive::binary_oarchive out_archive(ss);

out_archive << info;

Open in new window


So, now how can I send/receive out_archive using boost::asio asynchronously .. or
//boost::property_tree
boost::property_tree::ptree root;
root.put("id", 2);
root.put("name", "Rasul");

Open in new window

How can I send/receive root using boost::asio asynchronously??? (If you have some other ideas please share them)
0
i want to create one dialog control with three buttons dynamically and  same dialog to created dynamically again 12 dialog s with the same content and size  but 12 dialogs control  should appear tile in format.
0
Hello!

I am a new member and I saw that you already have some old posts regarding dxf libraries.
I found the topics very useful for my search but they are a bit old.
For this reason, I am creating a new post for new suggestions and ideas!

I am searching for C++ (or C) libraries which can read dxf files, preferably all versions.
I have an issue with the license type as I want to use it for a commercial software.
So, I need a library with license MIT, 3-clause BSD or commercial.

I would be grateful if you have any ideas!
Thank you very much for reading this post.
0
I'm using currently the project
https://support.microsoft.com/de-de/help/246227/sample-secumgr-exe-overrides-security-manager-for-webbrowser-host
to check if a web portal, for example http://fontello.com/, works fine with EOT, WOFF and TTF to displaying different icons.

It looks like fonts with the Content-Type application/vnd.ms-fontobject or application/font-woff could not be used with IWebBrowser2.
In the webtraffic i could see, that the app could download the fonts, but after the download i received the error E_ABORT in the IHttpNegotiate::OnResponse handler.

The web pages works in IE, but when we disable font download in the security settings we get the same 'problem' with the IE.

I tried to enable the font download in function IInternetSecurityManager::ProcessUrlAction
(URLACTION_HTML_FONT_DOWNLOAD) without a positive result.

What i'm doing wrong?
0
I have a short meta-programming approach for POD type safety from a previous question:
https://www.experts-exchange.com/questions/29056989/C-03-Templatize-Type-Safety-Enforcement-Part-2.html

I see the benefits of meta-programming as simplifying the development process for units - I believe that all new developers would have to do is to include a units header file, and follow a simple recipe for defining new data types.

I wrote in that question:
Other dimensional analysis areas that I am leaning towards:
 1. Make the class name part of the template
 2. Make the set of enumeration values part of the template so that they are not universally available
 3. Be able to operate on two different families of units. One obvious example would be:
        "distance (meters) = rate (meters/sec) * time (sec)".
     But we will have many other cross-unit operations as well.

I thought that I may as well see if I can get some tips on these ideas. If these 3 goals are realistic, but too much for one question, I am happy to work on what is reasonable for one question.

At the moment, I have to transcribe the previous question to my workstation, and then sell the ideas here and from the previous question to my lead software developer. The PM and Systems Engineer definitely like the idea of POD type safety. I just hope the lead likes the template approach.
0
NestingLayout.png
Here is my layout i need this in visual studio c# or c++ please help me to soft this problem. here i requested to give me idea to process layout like this,

thanks in advance
0
I would like to use Png images while working in C++ Builder RAD Studio XE6. I am using graphics32 lib and I managed to install runtime and designtime packages. I can put the TImage32 component on my form, then I load the png image in TImage32, but instead of transparency, I get white color on the background. I just cant see what do I have to do, to get transparent png image on my form.

I would be very thankful for your help.
0
Hi guys.

I'm using this code to read a text file locally and do the word search as needed but the problem is that the file which this app will be reading will be online on a web server and the problem is that the code I have now to read this text online I don't seem to figure out how I can split data so that I can still do word search just like how I do to a local file. Here is the code I use to read local file:

while(!in.eof() && getline(in, line, ','))
							 {
								if((offset = line.find(ID, 0)) == string::npos)
								{
									id = atoi(line.c_str());
									in >> dat;
									getline(in, NUMBER, ',');
									getline(in, line, '\n');
									
									KEY = (int)atof(line.c_str());
									
									if(ID ==id)
									{
										ID = id;
										//dst = dvs;
										va = KEY;
										
									}

Open in new window


Now this code part is the essential part of code as its what I want to be able to do in the following code which is the code that reads a file from the web.

    #include "stdafx.h"
    using namespace System;
    using namespace System::IO;
    using namespace System::Net;
    using namespace System::Text::RegularExpressions;
    int main(void)
    {
        Regex^ rxSubTitles = gcnew Regex("\\d.*>(?<subtitle>.*)<");
        String^ strFileIn = L"http://textfiles.com/adventure/221baker.txt";
        WebClient^ wc = gcnew WebClient();
        StreamReader^ fileWebIn = gcnew StreamReader(wc->OpenRead(strFileIn));
        String^ strData = "";
        while(!fileWebIn->EndOfStream)
        {
            strData = fileWebIn->ReadLine();
            if(rxSubTitles->IsMatch(strData))
            {
                // take ONLY the subtitle without additional decoration
                Console::WriteLine(rxSubTitles->Match(strData)->Groups["subtitle"]->Value->ToString());
            }
        }
        fileWebIn->Close();
        return 0;
    }

Open in new window

This code simply gets all the Titles.

Here is my text file structure:

111,7643876,2
324,254935,
730,021738248,1

Open in new window


As you can see each line has 3 data fields and
,

Open in new window

is the data separator and as you can also see that the 3rd field can sometimes be empty. I think if you can look at the structure and also look at my first code even though I didn't post the complete code on the first code but I think that s the main part which you may need as its also the main part I'm having problem with when trying to apply it to the second code.
0
Hello ,


Any body knows a sample for re-calculate checksums and drop packets on netfilter module ?

Thank you
0
Hello ,

We are building an IDS/IPS/Waf system that reads the packets from PF_Ring and apply rules to IPTables / Netfilter / Ntuple .
That software needs to access to userspace for iptables and kernelspace for netfilter. So we already pipe the both side.
But our main concern is about the performace issue. Time is our biggest enemy and need to solve the problem in mikro / mili seconds.
So where is the best place working area for our  main core of software for performance ? kernel area or user area ? and why .

Thanks for information
0
Hello ,

I want to know if there is a possible way to apply BPF filter to drop packets on netfilter  


Thank you



#define __KERNEL__
#define MODULE
#include <linux/ip.h>             
#include <linux/kernel.h> 
#include <linux/module.h> 
#include <linux/netdevice.h>      
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h> 
#include <linux/skbuff.h>         
#include <linux/udp.h>      

#include <linux/ip.h>


              
static struct nf_hook_ops netfilter_ops;                        
static unsigned char *ip_address = "\x5D\xBB\xCD\x73"; 
static char *interface = "p1p2";                          
unsigned char *port = "\x00\x17";                       
struct sk_buff *sock_buff;                              
struct udphdr *udp_header;                              
unsigned int main_hook(unsigned int hooknum,
                  struct sk_buff **skb,
                  const struct net_device *in,
                  const struct net_device *out,
                  int (*okfn)(struct sk_buff*))
{
  if(strcmp(in->name,interface) == 0){ return NF_DROP; }  
  struct iphdr* iph = ip_hdr(skb);
  if(iph->saddr == *(unsigned int*)ip_address){ return NF_DROP; }   
        
        
        
	/**sock_buff = *skb;
	if(!sock_buff){ return NF_ACCEPT; }                   
	if(!(iph)){ return NF_ACCEPT; }              
	if(iph->protocol != 17){ return NF_ACCEPT; }                 
	udp_header = (struct udphdr *)(sock_buff->data + (iph->ihl *4)); 
	

Open in new window

0
Hello

Is there any body knows ready to use sub routine when we send an array it will draw sth. like that :

value |-------------------------------------------------- count
    0 |                                                     32167
    1 |                                                      9999
    2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  1723569
    4 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@                        973472
    8 |@@@                                                 111055
   16 |                                                     14777
   32 |                                                       376
   64 |                                                       585
  128 |                                                        19
  256 |                                                         0
  512 |                                                         0

Open in new window

0
//************************** 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
0
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
0
language : c++
(tools : visual studio , acrobat reader)
thanks a lot
0
Let's say you have a COM interface,IWebBrowser2, it has a function, it has a function Navigate, Is there anyway that I can hook to this function, like I hook CreateProcess function in kernel32.dll?

Thank you for any help.

Evan
0
Hi,
I have a problem with custom templates not creating solutions correctly. It works fine on my Home computer but not on my office computer. I have reinstalled VS 2015 several times but problem remains. The issue is the "Location" and "Solution Name" dialog are not visible nor are the "Create directory for solution" or "add source to control" checkboxes and browse button.

Below is an example of what happens and below is one of the template files (this effects several new project templates under c++).

If I select New -> Visual C++ -> Empty Project, I get the following dialog at bottom of window (You can see that "Location Field" is Enabled and yet it does not show when I create a new project)



Name: Project 1
Location: C;\users\david\visual studio 2015\projects
Solution Name : Project 1
Also a "Browse" button, "Create directory for solution" checkbox and "add to source control" checkbox.

If I select New -> Visual C++ -> Particle Project (which is one of the custom projects) I get

Name : Sketch1

All the other dialogs and checkboxes are missing.

BUT, When I am on my computer at HOME, I see all the correct solution name, location and checkboxes ok, but NOT on my OFFICE computer.

I am sure it is related to some setting in a file somewhere that is overriding the parameters for the VM template but don't know which file will be controlling this behavior.

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" …
0
My work Environment :Qt 5.8 MSVC2015 64bit, QT GraphicsView, QGraphicsRectItem, Windows 7 64 bit.

Issues : When I zoom in & zoom out on GraphicsView, I call GraphicsView scale method. But When I add QGraphicsRectItem to scene it failed to call its paint method.

my class hierachy :

  class GraphicsView : public QGraphicsView
  class mySquare : public QObject, public QGraphicsRectItem
  class Scene : public QGraphicsScene 

Open in new window

Code :

//////*****Draw Rect in QGraphicsRectItem *****////////////

void mySquare::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
      QRectF rect(0,0,_width,_height);
      painter->drawRect(rect);
}

Open in new window


 
 void GraphicsView::wheelEvent(QWheelEvent * event)
{
    int angle = event->angleDelta().y(); // angle will tell you zoom in or out.
    double scaleFactor = 1.15; //How fast we zoom
    setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
    if (angle > 0)
    {
        qDebug()<<"Zoom in";
        scale(scaleFactor, scaleFactor);
    }
    else
    {
        qDebug()<<"Zoom out";
        scale(1.0 / scaleFactor, 1.0 / scaleFactor);
    }
        mySquare  _square = new mySquare(0,blankImage);
       _square->setPos(QPointF(0, 0));
       //add square to scene. 
] //Bug!!! Why after scale function call, _square failed to draw rect in paint method.
]        _scene->addItem(_square);
        _square->update(); 
}

Open in new window


My git gitcode
I spend days & hours but still not able to find out why it QGraphicsRectItem failed to print, when scale method get called. Any suggestion is highly appreciated ?
0

C++

57K

Solutions

24K

Contributors

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.