Click here to Skip to main content
15,898,010 members
Everything / Programming Languages / VC++

VC++

VC++

Great Reads

by Naveen
How local static variable is implemented in VC++
by Paolo Messina
Class library to make development of resizable windows a easier for the MFC developer and pleasant for the user
by Marc Richarme
Could be used to create a Visual C++ like search combo for CHtmlViews... With the update, you can highlight all matching words!
by The Ænema
This article brings you a very detailed but easy to learn experience on creating your own x64 PE packer/protector using only VC++!

Latest Articles

by Paolo Messina
Class library to make development of resizable windows a easier for the MFC developer and pleasant for the user
by David 'dex' Schwartz
Old style printf format strings ported to an ostream shim class
by The Ænema
This article brings you a very detailed but easy to learn experience on creating your own x64 PE packer/protector using only VC++!
by The Ænema
Learn how to convert any code to a stable shellcode using Visual Studio 2019 and VC++ in easy steps!

All Articles

Sort by Updated

VC++ 

19 Dec 2016 by #realJSOP
The cell's value can be a formula. Try this in your excel interop code (assuming you have excel interop code):string value = (string)(workbook.ActiveSheet.Cells[row, col].Value2);
3 Apr 2019 by #realJSOP
See if there are associated commandline parameters, config files, or failing that, registry entries that you can change. If there aren't any of those, your only recourse is to get the window handle and programatically, change the settings via the given app's UI (and not only is that ugly, but...
20 Jan 2020 by _Asif_
There is an Article on Code Project that does similar task and it also contains sample code as well. Try it WebService Call From VC++6.0[^]
30 Jul 2020 by _Flaviu
A guide to choosing and implementing a worker thread in your application
10 Nov 2021 by a_alise
In C# We Have This Below : private string Base64Encode(string plainText) { var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText); return System.Convert.ToBase64String(plainTextBytes); } How I Will Do It In VC++ 6.0 ...
30 Aug 2021 by Aashish_stellar
Hello, I am working on .xlsx file on windows in VC++ MFC and trying to create table in its worksheets. I am using XLS2007::ListObjects::add function for creating table but function fails every time. Please have a look what I am doing: What I...
20 Jan 2020 by AbhijeetMali
I am created illustrator plugin in c++. I want to call SOAP web service in plugin. i am trying bellow code but not getting responce. What I have tried: IServerXMLHTTPRequestPtr pXMLHTTPReq = NULL; hr=pXMLHTTPReq.CreateInstance(__uuidof(ServerXMLHTTP60)); hr =...
27 Jan 2020 by AbhijeetMali
i have a string value and i want to convert string value to TCHAR value. What I have tried: dont know how to convert in c++
7 Apr 2017 by abhilashmfc
Hi all, I was migrating our project from 2010 to 2015, but I was facing linking issue saying that atlsd.lib was not able to open. The installation folder for VS2015 "C:\LegacyApp\VisualStudio2015\VC\atlmfc\lib" doesn't have debug version of this lib, but it has release version "atls.lib" I have...
22 May 2021 by Abitha Barkath
I have a vc++ based ActiveX control which has edit box which shows "?" While typing romanian s cedilla.I am using GetWindowText() to get the text. Its legacy project and multibyte is set as charater type in project settings.Only S/T cedilla I am...
4 Mar 2019 by adityarao31
I can find window version and screen resolution through mfc by different available functions.But how to find display percentage magnification. For example 100%,150%,200% through mfc functions. Please let me know function names. What I have tried: I have googled for the...
28 Aug 2019 by adityarao31
For adding TLS 1.2 I found following string System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; But this string is not compatible with VC++ 6.0 unmanaged code. Task infront of me is to add TLS 1.2 support.Database used in SQL...
17 Dec 2020 by adityarao31
m_pReportAPI.CreateInstance("M...
17 Dec 2020 by adityarao31
MAXExact.ReportAPI is GUID.And I think some guidance I will able to get from COM programmer
23 Mar 2016 by Alya Wu
#include "stdafx.h"#include #include #include #include #include int t = 0;sf::RectangleShape addsnake();std::vectorsnake;sf::RectangleShape...
9 Feb 2017 by Anderson Rissardi
I have a little experience in add-ins with c#, but I believe that you will understand the concept.I believe that you should use Microsoft.Office.Interop classes with COM to create it.To find the current selected Microsoft.Office.Interop.Outlook.MailItem you can use this: ...
12 Mar 2017 by Anoha
iam using list control in mfc . pls help to change the color of list control of view record?
12 Mar 2017 by Anoha
i created a dialog box while clicking on the button.but when i again clicked again dialog box is creating. i want to create it on the first click. when the button is clicked further clicks should be disabled.can u help me to do this?What I have tried:i created a dialog box while clicking...
20 Mar 2016 by Arthur V. Ratz
To disable warning you normally use the pragma: #pragma warning( disable : warning-number-list )For example: #pragma warning( disable : 4705 )
29 Mar 2016 by CHill60
Even if we did we would not share this information with you.Hacking is not tolerated on this site.
27 Feb 2017 by chinnasamy t
I am trying to create the following scenarios tab control using MFC.Tab1 tab1 tab2Tab2 tab1 tab2I was created parent Tab control and can able to control the tabs. I can't find any example relating to this. If it is possible, any one share some examples or useful...
12 Sep 2016 by Coder Block
I am currently developing some addition code as dll for one third party executable. For debug of my DLL using third party exe, I am providing executable path in debugging property. Project propertyAll things are working properly unless they release new version of executable. They...
22 Jun 2017 by Coder969
We are migrating our project from vs2005 to vs2015 . In one of the project we are using Ad1.lib .When I build that project in vs2015 getting the error saying Ad1.lib not found . In vs2005 this lib was present in " C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\Lib " but I...
28 Jun 2017 by Coder969
We are migrating our projects from vs2005 to VS2015 .In one of the project we are using below template declaration template In 2005,it is building successfully but in vs2015 getting below error. 'WindowClass': illegal type for non-type template...
4 Jul 2017 by Coder969
We are converting our projects from vs2005 to vs2015. We able to clear the build error but now we are getting runtime error at LoadTypeLib function call Error is "Error loading type library/DLL" Below is the code HRESULT LoadTypeInfoFromThisModule(REFIID riid, ITypeInfo **ppti) { *ppti = 0;...
7 Apr 2020 by Coder969
I want to understand which hook is used for what purpose. What I have tried: I have googled and only difference I understood is WH_KEYBOAD will inject the dll into the processes but for the WH_KEYBOAD_LL windows will make a direct call to call back function without injecting the dll. So...
6 May 2020 by Coder969
We have a com dll from third party and using that com dll from the vb script. We want to remove the third party dll and write our own dll with same name and object so that we dont need to change anything in our scripting code. I created the new...
30 Jun 2020 by Cool Dude-P
CPoint point; ::GetCursorPos(&point); CEdit* pt = (CEdit*)GetDlgItem(IDC_SOMEID); DWORD dEditcontrol = SendMessage(EM_CHARFROMPOS,(WPARAM)0,(LPARAM)&point); int CharPostrion = HIWORD(dEditcontrol); int CharPo = LOWORD(dEditcontrol); What I...
30 Jun 2020 by Cool Dude-P
CEdit* pEditControl = (CEdit*)GetDlgItem(IDC_ID); POINT CaretPos; ::GetCaretPos(&CaretPos); pEditControl->SetSel(CaretPos.x, CaretPos.y); What I have tried: Can some one help me with this
7 Jan 2016 by CPallini
You know you might convert screen coordinates to client ones (or viceversa).As an alternative, you might detect when the mouse pointer 'exits' from your application window (see WM_MOUSELEAVE message[^]).
13 Jan 2016 by CPallini
Quote:Msg_t *new_node[10];The above line create an array of 10 pointers. Fine.Quote:new_node[0]->message_id = ...In order to make the above line work, new_node[0] must point to a valid Msg_t instance while it is pointing to garbage.You have to write something likenew_node[0] = new...
13 Feb 2016 by CPallini
As Richard pointed out, if you want to do socket programming then you have to use IP addresses (or hostnames, and anyway, you haven't to worry about the IP address assigned to your own ethernet card). In order to start with socket programming you have to read the f#*?+° (fantastic)...
14 Feb 2016 by CPallini
Let's see if we have one or two articles on such a topic, here at CodeProject[^].
26 Apr 2016 by CPallini
There are several ways to accomplish such a task. You can, for instance, use the Tokenize[^] method to extract all (the string representations of) the octects ant then convert each string to the corresponding byte (e.g. using itoa[^]).
4 May 2016 by CPallini
With the Microsoft C++ compiler, the way to go is the pragma pack[^].
8 Jun 2016 by CPallini
See I want to add/remove ES_PASSWORD(CEdit) style, dynamically.[^].
12 Jun 2016 by CPallini
If you mean "open the file with another application" the have a look at Launching Applications (ShellExecute, ShellExecuteEx, SHELLEXECUTEINFO)[^].
9 Sep 2016 by CPallini
Did you try the Code Project search engine[^]?
3 Oct 2016 by CPallini
Your bVisble variable is never initialised.
12 Dec 2016 by CPallini
See this Code Project article: "An Introduction to a Model-View-Controller Implementation for MFC"[^].
21 Feb 2017 by CPallini
Quote:LoadLibrary(L"C:\\Progra...
26 Feb 2017 by CPallini
Here at CodeProject you may find a lof of articles on reading/writing values from/to the registry[^].You might also use the WriteProfileString function (Windows)[^] for such purpose.
28 Feb 2017 by CPallini
In order to write, you may either use a loop, calling at each iteration SetWORDValue or SetQWORDValue (as appropriate) or, without the loop, calling just one time SetBinaryValue (see CRegKey Class[^]).You may read back the data in a similar way.You might also have a look at one (or more)...
9 Mar 2017 by CPallini
Just disable the button after first click, see CWnd::EnableWindow[^].
1 May 2017 by CPallini
Did you already ask Google? See, for instance: Common Visual C++ 64-bit Migration Issues[^].
29 Aug 2017 by CPallini
Extract the octects (bytes) from the IP strings (you may find many examples just Googling[^]) and then compare them.
10 Nov 2017 by CPallini
Make an accessor (a public method) in order to manipulate the protected property.
10 Nov 2017 by CPallini
Have a look at Newcomer's Threads and Processes series. Please note 50 ms is a relatively short time for Windows OS. Moreover, in order to keep your application responsive the 'active' (i.e. not sleeping) part of your code should be a small fraction of 50 ms (that is your thread should be...
11 Dec 2017 by CPallini
Download it[^] and try (using at first a C++ Console project) to compile and run some of the examples.
21 Jan 2018 by CPallini
In addition to Richard solution, have a look at c++ - Is it bad practice to allocate memory in a DLL and give a pointer to it to a client app? - Stack Overflow[^]. Unfortunately mismatches between allocator and deallocator do happen and are not pleasant.
30 Jan 2019 by CPallini
Quote: int nfRet = SockConnection.Send((char*)&command_header, sizeof(command_header)); nfRet = SockConnection.Send(command_header.iDataBuffer, sizeof(command_header.iDataBuffer)); The above calls don't make sense. On my system sizeof(command_header)=8 ...
12 Feb 2019 by CPallini
COM interfaces are immutable you shall not try to change them. You have to create new interfaces. From the documentation[^]: COM interfaces are immutable. You cannot define a new version of an old interface and give it the same identifier. Adding or removing methods of an interface or changing...
3 Jul 2019 by CPallini
Have a look at this code samples: MFC Sockets[^]. Have also a look at this CodePrject article: Sending & Receiving UDP Datagrams with MFC's CAsyncSocket C++ Class[^].
26 Sep 2019 by CPallini
A quick and dirty search result: TIP: Adding a typelibrary as a resource to a project[^].
23 Sep 2019 by CPallini
Could be a name clash. Try to change the name of the class or, better, enclose it in a namespace. By the way, the compiler message should indicate where it was already defined.
27 Jan 2020 by CPallini
Quote: i have a string value and i want to convert string value to TCHAR value. A string is a sequence of characters, while TCHAR is a single character (either char or wchar_t as already pointed out by Richard), so you cannot convert. As a wild guess, I suppose you need to convert from a string...
1 Sep 2020 by CPallini
What about the documentation[^]? I've underlined it for you: Because of their potential for security issues, by default, these functions cause deprecation warning C4996: This function or variable may be unsafe. Consider using safe_function...
18 May 2016 by cppcoder1
Hi,I have a tree control and I want to set focus on the top most item.Im using the following function but its not setting.HTREEITEM htiRoot = m_treeAvailableGraphs.GetRootItem(); m_treeAvailableGraphs.SetItemState(htiRoot, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED |...
26 Jul 2016 by cppcoder1
Hi All, I'm trying to declare a CPen object in class scope and using it in OnDraw(...).But my application is crashing when I run it.If I declare the object in OnDraw(...) it is working fine. Can anyone please let me know do I need to any extra thing if declare CPen object in class scope? Thanks...
5 Feb 2017 by cppcoder1
Hi,I'm calling a modal dialog from a java application. But if I click out of that, dialog is minimizing which I don't want because it is a modal dialog box. I have tried by giving property WS_EX_TOPMOST but it is always showing dialog on top even if I switch to other applications.I have...
2 Feb 2016 by Dave Kreskowiak
"CodeProject" did not write the control. The person who wrote the article you got the control from wrote the control.There is a forum at the bottom of the article your got it from. Post your question there and the author should support the code he wrote.
13 Feb 2016 by Dave Kreskowiak
You obviously have no idea what a MAC address is or what it's used for.You can NOT use a MAC address to talk to a device from your application. It is a hardware address used to uniquely identify a device on a physical network segment and ensure a physical signal gets to the correct device on...
27 Sep 2016 by Dave Kreskowiak
If you're talking about executing an .EXE on the client, you can't. That's a MASSIVE security risk and is not allowed.
2 Feb 2017 by Dave Kreskowiak
If you're asking if Windows sends or broadcasts any message when a drive is formatted, the answer is no.
8 Feb 2018 by Dave Kreskowiak
You don't. UDP has no guarantees of delivery nor in the order that packets show up at the receiver and the possibility of duplicate packets also exists! There is NO WAY around this. If you want "reliable" data transfer, UDP is the LEAST reliable transport there is. You're going to have to use...
9 Oct 2018 by Dave Kreskowiak
It's probably because you're using a trusted connection in your connection string. Using a Trusted Connection means that the user credentials presented to the database to login are the ones the code is running under. In the case where your database code works, the code is running as YOU. In...
18 Sep 2019 by Dave Kreskowiak
Unless you've got some kind of server running on the target machine that will retrieve the contents of memory and send it to your client, it's impossible to get the memory of a remote machine.
25 Sep 2022 by David 'dex' Schwartz
Old style printf format strings ported to an ostream shim class
4 May 2016 by debarunb
In want document View application holding some button and some menus after clicking that button or the menu respective dialog box should appear.And I have to pass some data from document view to dialog also.So can anyone help me to solve this issue or share some code or link ...What I...
17 Dec 2018 by dhaya sagar
I need code to read data from text file and display the data in Tree Control...With a condition if, the text in the file not preceded by tab, it should be in parent node and if preceded by tab, it should be in child node. Example: Notepad contains two lines..... Hello -> (not preceded by tab...
31 Mar 2017 by dilsdgr8
Iam developing an MFC Dialog application that is stored in DVD. Suppose User runs this application from DVD and eject DVD while the application is running. Is it possible to close the application by default.What I have tried:I have handled WM_DEVICECHANGE notification and invoked...
17 Mar 2018 by dilsdgr8
Iam creating an application that requires to store passwords in file. Iam planning to use CArchive. I want to encrypt the data before saving. After googling i think BCryptEncrypt is the only option. Which algorithm is best for password saving. Please advice. Please provide any sample code also ...
21 Mar 2018 by dilsdgr8
I used SHA256 algorithm for getting hash. THe hash produced by my application is not same as the one generated by online tools for the same string. What I have tried: BCRYPT_ALG_HANDLE hAlg = NULL; BCRYPT_HASH_HANDLE hHash = NULL; ...
3 Dec 2019 by Donguy1976
I am writing code in C++ on Visual Studio 2015 and using standard XML libs that comes with Windows APIs.Below is a sample XML file that i have. 1.0.1 Sample XXX ...
8 May 2018 by Donguy1976
I'm having a dialog based app written in VC++ using Visual Studio 6. It's a simple app with very few texts, but now those needs to support multiple languages. As it's not many texts, the plan is to add all the different languages into just one string table with a unique identifier. So now a...
8 Feb 2019 by Donguy1976
This is more of a design suggestion that I want to hear from C++ experts here. I have a C++ DLL in VS 2015 IDE. I want to add more exception handling into this code. Currently there's a function as follows. void Metrics::GetNumbers(InputParams* input, OutputParams* output) { int i, x, k; ...
10 Sep 2018 by Eshwar Reddy
I need to select columns of text when alt and mouse left key is down and dragged. I need to implement the operation which exists in visual studio as we select columns of text with alt and mouse left key is clicked and dragged. Thanks in advance What I have tried: I dont have any idea of...
29 Aug 2017 by forest-321
It can be compared with dword type. For example, you can use follow macros. #define str2dword(sip, ip) { \ DWORD _2, _3, _4; \ _stscanf_s(sip, _T("%d.%d.%d.%d"), &ip, &_2, &_3, &_4); \ ip = ip | (_2
13 Feb 2016 by Frankie-C
You can use raw socket programming to exchange packets on low level using Ethernet protocol.Ethernet use a binary address unique for each comm card made of 6 octects named MAC, that is the short for Media Access Control address, a hardware address that uniquely identifies each node of a...
11 May 2016 by gail hedberg
i have a simple sizing dlg with a richedit 2.0 control - 2 problems:1 - i do not see how to apply formatting - do i someho need to capture right click and create a context menu?2 - when the data is retrieved from the ctrl, there is no formatting instructions so it's saved as plain txt to the...
7 Oct 2016 by Garth J Lancaster
Given you dont show us any code its a bit of a guess for us as to how to help you. In short, if you're using PROCESS_INFORMATION processInformation = {0};in your call to CreateProcess, you can then WaitForSingleObject( processInformation.hProcess, INFINITE );DWORD exitCode;BOOL...
4 Apr 2019 by Gerry Schmitz
Yes; it's called "Movie Maker".
30 May 2016 by Haris1228
void CSocketClientDlg::OnBnClickedSendmsg(){ // TODO: Add your control notification handler code here UpdateData(TRUE); if(m_sSendMsg.GetLength() == 0) { MessageBox("Type your Message !"); return; } CString sStr = ":"; CString sUserName = m_sUserNmae +sStr+...
18 Jan 2017 by Jagssnaik
I am working on a project where I am interacting between the components of VC++ (Server) and C# Client.The C# component is been triggered by VC++ and further interactions happens between these components over Control Pipes.The Control pipe is created at the VC++ as...
28 Sep 2017 by JMihailescu
You may derive your own class from CVSListBox and override the virtual method BOOL EditItem(int iItem){return FALSE;} returning false. Since the new and delete buttons may be useless in this situation you may remove any of them by setting the desired flags in SetStandardButtons(UINT uiBtns =...
6 Jan 2016 by Jochen Arndt
You can try the other method described here: Adding a Member Variable[^].If this does not help do it manually by adding the variable definition to the dialog header file and map the list control to the variable in the dialog class DoDataExchange[^] function using DDX_Control.
13 Jan 2016 by Jochen Arndt
Enhancing my comment post as answer with a reasonable error source.The LoadImage() call with path and LR_LOADFROMFILE should work. If it fails (return value is NULL), you should call GetLastError() to get an error code and optionally look up the error message.If the error code is 5...
25 Feb 2016 by Jochen Arndt
CArchive is not intended to read common text files. It is used to save and store a binary representation of the data used by your application (commonly the data hold by your CDocument class). If you use the CArchive string functions, they will use Unicode strings with Unicode builds and...
23 Mar 2016 by Jochen Arndt
You are creating a CTest instance on the stack and trying to delete it aftwerwards. That will of course crash because you can only delete objects that has been allocated on the heap using new.So you would probably want to do something like this (depending on the type of the second std::pair...
30 Mar 2016 by Jochen Arndt
Handle the NM_CLICK (list view) notification code (Windows)[^] and NM_DBLCLK (list view) notification code (Windows)[^] notification messages in your parent window. The LPARAM parameter for these messages is a pointer to a NMITEMACTIVATE structure (Windows)[^] containing all necessary...
4 Apr 2016 by Jochen Arndt
Really VC 5? For which Windows version?Since Windows NT normal applications have no direct access to hardware. You always need a driver.Because parallel ports are outdated, it is difficult to find still working examples. But this site may be a good starting point: Jan Axelson's Lakeview...
6 Apr 2016 by Jochen Arndt
The rightmost parameters are for the source which is probably the original (not zoomed image). So you have to calculate the destination parameters (the left most ones).To support zoom in/out you must track the actual zoom factor in a variable that is initialised with 1. Then adjust this upon...
14 Apr 2016 by Jochen Arndt
It is not quite clear what you are looking for but I will try to answer.If you want to make updating the list items faster, you can disable redrawing while inserting and changing items:// Disable redrawing while updating the listSetRedraw(FALSE);// Add or update items...
26 Apr 2016 by Jochen Arndt
This has been asked and answered multiple times. It is just a question of finding the correct search term. I used "c++ parse ip string" and got a lot of useful results:C++ how to convert ip address to bytes? - Stack Overflow[^]c - parsing ip adress string in 4 single bytes - Stack...
15 Jun 2016 by Jochen Arndt
See CListCtrl::EditLabel[^].If you want a different behaviour you have to implement it yourself. Some examples from CodeProject:Editing Sub-Items in List Control[^]In-place editing of ListView subitems[^]An Extended MFC CListCtrl to edit individual cells, sort headers, and...
22 Jun 2016 by Jochen Arndt
In your OnNMClickList2100 handler you are selecting an item (a row) when clicked on it. But this will not remove the selection from other actually selected rows so that you may have multiple selected rows.What is the purpose of handling that on your own? The default handling will select the...
23 Jul 2016 by Jochen Arndt
See the CodeProject article MFC under the hood[^]. It explains the startup and initialisation process of MFC applications describing which functions are called.
26 Jul 2016 by Jochen Arndt
You are calling CreatePen again and again with each drawing.The simplest solution would be calling CreatePen in the constructor of your class and remove it from the draw function:CMFCApplication2View::CMFCApplication2View(){ // Other initialisation goes here ...
26 Jul 2016 by Jochen Arndt
Some of your example strings are not valid URLs (see Uniform Resource Locator - Wikipedia, the free encyclopedia[^]) or valid URIs (Uniform Resource Identifier - Wikipedia, the free encyclopedia[^]). So you have to define first what is allowed / to be supported.This might be for example that...
29 Sep 2016 by Jochen Arndt
The EN_CHANGE notification is send whenever the text is changed by user input or by setting the text using SetWindowText() / WM_SETTEXT for single line edit controls.You have probably one or more places where the edit control is initialised when the parent window (a view in your case) is...