Please help Ukrainian armed forces! Official Fundraising

How to make Windows Apllication Run as Administrator?

1 1 1 1 1 How to make Windows Apllication Run as Administrator?5.00Rating 5.00 (1 Vote)

With the evolution of Windows, the security requrements has been also risen up. In Windows 10 all applications are run under a lowered user account, which has no access to system folders, system registry entries and so on. The app is limited to something like a sandbox. But what to do if you need to acces to system files and registry keys? You need to run your application as a computer Administrator. This is done through the Windows process called "Elevation". How to run Windows Application as elevated or Administrator account? You will need to add a special entry in your .manifest file when you build your application. A Manifest file is a special sattelite file for your .exe that tells the system how to treat your program. If you don't have a .manifest file, you will need to create one. Also, your file should be linked as Embedded Manifest only. Side-by-side manifests are not supported for elevation.

Read more: How to make Windows Apllication Run as Administrator?

How to create a window on a separate desktop in Windows

1 1 1 1 1 How to create a window on a separate desktop in Windows5.00Rating 5.00 (1 Vote)

It's not a secret that Windows 10 has several desktops. The previous Windows versions had separate desktops as well, but only the default was accessible by applications by default. When you need to create a window on a separate desktop, you can use the sample code from this article.

The code below creates a separate thread for the desktop and runs a separate message loop in it. This is necessary because the default application message loop is not intended to rum on multiple desktops. 

 


void CreateDesktop2()
{
	CString sDeskName;
	sDeskName.Format("DeskTop%x",GetTickCount());
		
	HDESK hDesktop2 = CreateDesktop(sDeskName,
	NULL,NULL,0,STANDARD_RIGHTS_ALL|DESKTOP_CREATEMENU|DESKTOP_CREATEWINDOW|
	DESKTOP_ENUMERATE|DESKTOP_HOOKCONTROL|DESKTOP_READOBJECTS|
	DESKTOP_SWITCHDESKTOP|DESKTOP_WRITEOBJECTS,NULL);
	if(hDesktop2 == NULL)
		AfxMessageBox("Error in CreateDesktop",MB_OK,0);
	HDESK hUserDesktop = GetThreadDesktop(GetCurrentThreadId());
	HTHREAD hThread = (HANDLE)_beginthreadex(NULL,0,DeskThread,this,0,(unsigned*)&m_dwThreadId);
}
UINT DeskThread(LPVOID lpParam)
{
	MSG msg;
	
	SetThreadLocale(LOCALE_SYSTEM_DEFAULT);
	SetThreadDesktop(hBlockDesktop);
	if (p->m_wnd_desk.Create())
	{
                /// CREATE YOUR WINDOW HERE
		///p->m_waker_dlg.Create(CWakerDlg::IDD,&p->m_wnd_desk);
		while(::GetMessage(&msg,0,0,0)!=0)
		{
			if (!IsDialogMessage(p->m_waker_dlg.m_hWnd,&msg))// to process keyboard messages
			{
				::TranslateMessage(&msg);
				::DispatchMessage(&msg);
			}
		}
	}
	else
	{
		::MessageBox(0,"DeskThread failed",NULL,MB_OK);
	}
	p->m_waker_dlg.DestroyWindow();
	p->m_wnd_desk.DestroyWindow();
	SetThreadDesktop(p->m_hUserDesktop);
	SwitchDesktop(p->m_hUserDesktop);
	
	_endthreadex(0);
	return 0;
}

 

WM_MOUSEMOVE message

1 1 1 1 1 WM_MOUSEMOVE message5.00Rating 5.00 (1 Vote)

The WM_MOUSEMOVE Message is posted to a window when the cursor moves. If the mouse is not currently captured, this message is posted to the window that contains the cursor. If the mouse is captured, the WM_MOUSEMOVE message is posted to the window that has captured the mouse. A window receives this message through the windows procedure function.

Read more: WM_MOUSEMOVE message

How do I make a JSON object with multiple arrays?

1 1 1 1 1 How do I make a JSON object with multiple arrays?5.00Rating 5.00 (409 Votes)

{
"cars": {
"Nissan": [
{"model":"Sentra", "doors":4},
{"model":"Maxima", "doors":4}
],
"Ford": [
{"model":"Taurus", "doors":4},
{"model":"Escort", "doors":4}
]
}

 

Source: https://stackoverflow.com/questions/11197818/how-do-i-make-a-json-object-with-multiple-arrays/11197949

Arrays in JSON

1 1 1 1 1 Arrays in JSON5.00Rating 5.00 (921 Votes)

Example

[ "Ford", "BMW", "Fiat" ]


Arrays in JSON are almost the same as arrays in JavaScript.

In JSON, array values must be of type string, number, object, array, boolean or null.

In JavaScript, array values can be all of the above, plus any other valid JavaScript expression, including functions, dates, and undefined.

Arrays can be values of an object property:

Example
{
"name":"John",
"age":30,
"cars":[ "Ford", "BMW", "Fiat" ]
}

The objects returned from most Server APIs are highly nested:

{
"id": "0001",
"type": "donut",
"name": "Cake",
"ppu": 0.55,
"batters":
{
"batter":
[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" },
{ "id": "1004", "type": "Dog's Food" }
]
},
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" },
{ "id": "5005", "type": "Sugar" },
{ "id": "5007", "type": "Powdered Sugar" },
{ "id": "5006", "type": "Chocolate with Sprinkles" },
{ "id": "5003", "type": "Chocolate" },
{ "id": "5004", "type": "Maple" }
]
}

Sourceы: https://www.w3schools.com/js/js_json_arrays.asp  https://adobe.github.io/Spry/samples/data_region/JSONDataSetSample.html

Introduction to JSON

1 1 1 1 1 Introduction to JSON5.00Rating 5.00 (683 Votes)

JSON is a text format that facilitates structured data interchange between all programming languages. JSON
is syntax of braces, brackets, colons, and commas that is useful in many contexts, profiles, and applications.
JSON was inspired by the object literals of JavaScript aka ECMAScript as defined in the ECMAScript
Language Specification, third Edition [1]. It does not attempt to impose ECMAScript’s internal data
representations on other programming languages. Instead, it shares a small subset of ECMAScript’s textual
representations with all other programming languages.

Read more: Introduction to JSON

cJSON: Lightweight JSON parser

1 1 1 1 1 cJSON: Lightweight JSON parser5.00Rating 5.00 (518 Votes)

If you are searching for cJSON usage samples, or example code that you can just copy-paste into your C project, you came to the right place. 

cJSON is one of the simple JSON parser that you can get your job done with. It's a single file of C, and a single header file.

JSON is described best here: http://www.json.org/ It's like XML, but fat-free. You use it to move data around, store things, or just generally represent your program's state.

As a library, cJSON exists to take away as much legwork as it can, but not get in your way. 

There are several ways to incorporate cJSON into your project, one of them is just copying the source.

Because the entire library is only one C file and one header file, you can just copy cJSON.h and cJSON.c to your projects source and start using it.

cJSON is written in ANSI C (C89) in order to support as many platforms and compilers as possible.

Read more: cJSON: Lightweight JSON parser

How to change the master sound volume in Windows Programatically

1 1 1 1 1 How to change the master sound volume in Windows Programatically5.00Rating 4.98 (259 Votes)

Many C++ developers already know CVolumeOutMaster classes by Alex Chmut, published on CodeProject. These classes allow easily regulate and track the changes of such volume controls as Output Master Volume, WaveOut Volume and Input (WaveIn) Volume

Unfortunately these classes are not compatible with Windows 7. But in factm It's actually easier in Windows 7 Vista than it was in XP.  For Windows 7, you have to use IAudioEndpointVolume COM interfaces.

A tiny app that demonstrates IAudioEndpointVolume COM interfeace for setting master volume. To save space, all error checking was removed.

Read more: How to change the master sound volume in Windows Programatically

Is MFC dead? Does MFC have a future?

1 1 1 1 1 Is MFC dead? Does MFC have a future?5.00Rating 4.92 (252 Votes)

“Is MFC dead?” is arguably the most common question appearing on the VC++ newsgroups along with variants like “Does MFC have a future?” and “Can MFC applications run on Windows 10, 11, etc.?”. A short answer would be, “No, MFC is not dead, and you can continue to develop applications using MFC and be assured that they will run on Windows 10” For a more involved answer, continue reading.

What makes a technology dead? The fact that nobody uses it any more? If so, MFC is not dead now nor will it die in the next 20 years – because, the number of people using MFC must be in the millions right now and even assuming that newer adopters would be fewer as the years go by, the amount of MFC code is so extensive that there will be a large number of developers continuing to work on it. Okay, so that definition of death wouldn’t apply here. How about considering a technology to be dead if its development is frozen? If so, same results – MFC is simply not dead! MFC has got some new additions (mostly classes that allow it to interact easily with Windows Forms) and MFC will continue to be enhanced by third-party developers. Okay, so all this talk of a dead MFC is rubbish! Next point.

Read more: Is MFC dead? Does MFC have a future?

What’s up with MFC in Visual Studio 2011 Beta

1 1 1 1 1 What’s up with MFC in Visual Studio 2011 Beta5.00Rating 5.00 (826 Votes)

Hello, I’m Pat Brenner, a developer on the Visual C++ Libraries team. Through this blog post I wanted to share some information about the Microsoft Foundation Class (MFC) Library, since I am the primary developer working on MFC.

As you know, MFC is an important technology component which has been extensively used over the years by C++ developers to build desktop applications for Windows. In every product release, we make enhancements to the library, whether it is taking advantage of features in newer versions of the Windows operating system or adding fixes for common developer issues. With the recent release of Visual Studio 11 Beta, there have been some concerns among the MFC developers about the apparent lack of focus on MFC.

Read more: What’s up with MFC in Visual Studio 2011 Beta

Tuesday the 19th.