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

Calling a function from CreateProcess [MSVE 2013 for windows desktop][VC++ project]

$
0
0

Hi All,

         I went through the createprocess function documentation on MSDN website.

however i could not find a way to call a function using createprocess. Here are brief details of what i am trying to do

1.  main process [a running program itself is a main process]. i am running a program in MSVE  2013 for windows desktop.

2. that main process receives user inputs via CMDLINE.

3. main process is a simple program waiting for  user input commands and spawn a process [i.e. createprocess]. Assume display prompt something like  [=main=>].

4. say i issue command A , B and C.

5. Based on input A, program need to createprocess on existing .exe [executable] and it is up and running. 

6. Based on input B, program need to invoke a function. please note this function B has its own cmdline interface  [=CMD=>] and that  [=CMD=>] need to intake arguments [since it is now a seperate PROCESS, i expect it to act on its own] and be able to receive inputs via [ [=CMD=>]] and then call a function. please note my function B has inbuilt PROMPT capability.

7.  similar like step 6, i want same functionality for step 7 as well [i.e. input C]. prompt is something like =C=>. function C is here. please note my function C has inbuilt PROMPT capability.

objective at the end: - 

=main=> will take inputs A and then run a executable

=CMD=> will take inputs B and should act independently run a executable and simultaneously take inputs from different prompt

=C=> will take inputs B and should act independently run a executable and simultaneously take inputs from different prompt

now questions,

1. How can i link or hook a function to createprocess function.

2. please note my functionality can change within the 6 and 7, so i CANNOT afford to make function B as an executable and function C as an executable and call them as cmdline

3. can i use createprocess within a function called by createthread() ??

4. basically, when i create a process, i need to trigger a callback function

Thanks

RC Reddy



Access .NET 4.5 DLL from 2.0 Application

$
0
0

We have upgraded one application to .NET 4.5.2 Framework, and also we have some older application built in .NET 2.0.

The issue here is, the 2.0 Application cannot find the 4.5 dlls which is under the new GAC (%windir%\Microsoft.NET\assembly). I think 2.0 application still looks in old GAC.

Any configuration changes will fix this issue?

Please suggest some solutions. Thanks.

Microsoft.Windows.Common-Controls version for Windows 8 / Windows 10

$
0
0

Hello,

according to https://msdn.microsoft.com/en-us/library/windows/desktop/hh298349%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

the version for Windows Vista, Windows Server 2008, and Windows 7 is 6.10.

I'm porting old projects to Visual Studio 2015 Update 1. In the AdditionalManifestDependencies there is a line 

<AdditionalManifestDependencies>type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies)</AdditionalManifestDependencies>

it seems to be version 6.0.0. 
And according to this linkhttps://msdn.microsoft.com/de-de/library/wwtazz9d.aspx I should add 6.0.0, so what is the corrects setting for Windows 8 and Windows 10 when compiling with Visual Studio 2015 Update 1?

Thanks,


Andreas

how to read character

$
0
0

I am using visual studio 2015 community. I am a new user that's why every thing come new. some keyword is little bit different from other compiler. Can anybody tell me how many keyword is different from other compiler. especially error code C4473 

 

MFC Feature Pack support for highres displays

$
0
0

Hello everybody, I got a new monitor with support for 3840x2160 resolution and I started testing the MFC how it behaves when launching applications with highres DPI. I setup scaling of 200% in OS. It seems that MFC adapts the application automatically but there is a problem which I cannot solve. All the resources in MFC are automatically upscaled using CMFCToolBarImages::SmoothResize and that's exactly my problem :-). All the bitmaps look blurry. I tried to overcome this behavior but not with 100% success. In new MFC there are 2 variables which I found till now which controls the scaling:

CMFCToolBar::m_bDontScaleImages -> if set to TRUE, toolbars don't resize the input images

GetGlobalData()->EnableRibbonImageScale(FALSE); -> if set disabled (passed FALSE value), the rest of menus are not resized.

I am using MFC with classic menus and toolbars so I focused only on this part and not on ribbons, but I suppose that there is additional problems also in ribbons. I would like to disable any internal scaling of MFC and provide my own resources which are already prepared for the highres. So at the beginning I check the scaling GetGlobalData()->GetRibbonImageScale(), then disable it and use the returned value to determine which resources for the UI should I load from DLL. Everything seems to be ok except the CMFCCustomizeButton. The icon on it is too small without MFC automatic resizing. The icon is drawn through CMenuImages -> and this class is too hardcoded - using static members, static variables and delayed initialization there is no way to provide custom bitmaps. If tries to load a resource with ID = IDB_AFXBARRES_MENU_IMAGES24 or IDB_AFXBARRES_MENU_IMAGES (according to GetGlobalData()->Is32BitIcons()). It seems that this part is missed from customizing the look-and-feel of the application. Is there any way how to fix it?

Visual Studio 2015 Update 1: What is the meaning of AFX_DESIGN_TIME, didn't find any information about it

$
0
0

Hello,

when I create a new C++ MFC application with the wizard (all settings default) and add a new dialog to the resource and execute AddClass from the context menu I get the following code in the public section of the dialog class header file:

// Dialog Data
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_DIALOG1 };
#endif

In the source file IDD_DIALOG1 is used. So is it needed anywhere?

Thanks,



Andreas

fatal error C1001: An internal error has occurred in the compiler

$
0
0

Hi,

I have problem when I am building project in Visual Studio 2010 for 64bit. I couldn't able to build for 64bit with boost library, I am getting below error. I can build for 32bit but not for 64bit.

"\boost_1_49_0\boost\thread\win32\basic_timed_mutex.hpp(159): fatal error C1001: An internal error has occurred in the compiler"


Can you please help me,

Thank you





VS2008, VC++, unordered_map and unordered_set are not colour coded. Why not?

$
0
0
Using Visual Studio 2008, VC++.

When I open the headers 
<unordered_map>
<unordered_set>

which are in namespace tr1, I notice that it is all in black-on-white. It is not colour coded.
That is different from

<map>
<set>

There must be a master list of what VC++ colour codes.

How do I change this?

Thanks

IdentityWrapper

IdentityWrapper


How to get drive letter for USB Device from Device InstanceId ?

$
0
0

Hi,

I would like if there is any chance of getting drive letter for a usb device, in my case external hard drive with USB port, from a Device Instance ID while getting through the function SetupDiGetDeviceInstanceId().

if ( SetupDiGetDeviceInstanceId(hDevInfo, &spDevInfoData, devInstId, sizeof(devInstId), &nSize) )
{
}
By using this devInstId can we get the corresponding drive letter for the external hard drive?

This checking is under DBT_DEVTYP_DEVICEINTERFACE in DBT_DEVICEARRIVAL case under WNdProc.

if( pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
{
//if( ((PDEV_BROADCAST_DEVICEINTERFACE)pHdr)->dbcc_name !=csPrevdbccName)
{csPrevdbccName = ((PDEV_BROADCAST_DEVICEINTERFACE)pHdr)->dbcc_name;
	unsigned int threadID;
	//////////////////////
	DeviceChangeData *deviceData = new DeviceChangeData();
	deviceData->cs_dbccname =((PDEV_BROADCAST_DEVICEINTERFACE)pHdr)->dbcc_name;
	deviceData->dwFlag = DBT_DEVICEARRIVAL != wParam ?
	DIGCF_ALLCLASSES : (DIGCF_ALLCLASSES | DIGCF_PRESENT);
	HANDLE hThread = (HANDLE)_beginthreadex( NULL, 0, CCurrentWareAgentDlg::DeviceArrivalThread ,(LPVOID)deviceData, 0, &threadID );
}
And in the DeviceArrivalThread we are calling SetupDiGetDeviceInstanceId() to get the Device InstanceId.

How can I create manifest file in 'Release' folder ?

$
0
0

Hi All,

I wish to create manifest file in 'Release' folder; it must be updated on the basis of build or re-build...etc. And right now my test application contains only ".exe" and ".pdb" files in the 'Release' folder. I am using visual studio 2012 with Visual C++. Attached the screenshot of project properties:

Anyone please help me to create the manifest file.

R-VR

Microsoft CryptoAPI: how to convert PUBLICKEYBLOB to DER/PEM?

$
0
0

I have a generated RSA key pair stored as PRIVATEKEYBLOB and PUBLICKEYBLOB, and I need to be able to convert these keys to DER or PEM formats so I could use it in PHP or Python. I figured out that I could use CryptEncodeObject function to convert my PRIVATEKEYBLOB to DER. In order to do that I need to use PKCS_RSA_PRIVATE_KEY encoding flag. But I couldn't find any clue on how to convert PUBLICKEYBLOB to DER.

Here is my code for PRIVATEKEYBLOB convertion:

LPCSTR type = PKCS_RSA_PRIVATE_KEY;
DWORD  encd = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;

DWORD dlen = 0;
if(!CryptEncodeObject(encd, type, key, null, &dlen))
{ LOG_ERROR(); return false; }

// Buffer allocation (der variable)

if(!CryptEncodeObject(encd, type, key, der, &dlen))
{ LOG_ERROR(); return false; }

I test my keys by comparing them to the output of openssl tool:

openssl rsa -pubin -inform MS\ PUBLICKEYBLOB -in pub.ms -outform DER -out pub.der
openssl rsa -inform MS\ PRIVATEKEYBLOB -in pri.ms -outform DER -out pri.der

How to call one EXE method from another EXE module

$
0
0

I have two EXE modules(exe1 and exe2). I need to call an API of exe1 in the exe2. so how do i do it?

Please help me in solving this problem.


VC++ Windows Service application cannot Capture Screenshot

$
0
0

Is there any chance a Windows Service application can get a screenshot of current desktop with 2 monitors.

These was code in service application.

int iMonCount = GetSystemMetrics(SM_CMONITORS);

unsigned int totalWidth = GetSystemMetrics( SM_CXVIRTUALSCREEN );
unsigned int totalHeight = GetSystemMetrics( SM_CYVIRTUALSCREEN );
unsigned int PrimaryMonWidth = GetSystemMetrics( SM_CXSCREEN );
unsigned int PrimaryMonHeight = GetSystemMetrics( SM_CYSCREEN );

Here iMonCount returned only 1, but there is 2 monitors.

totalWidth returned was 1024 and PrimaryMonWidth retuned 1024 also, but PrimaryMonWidth is 1366.

Also this code returned corrrect parameters when coded in another application running on user session.


CRecordset - how to read specific fields from Excel?

$
0
0

Hello everybody! :-) Need help with my task: trying to create program for reading Excel documents using CRecordset (ODBC). So the original Excel sheet looks like:

date                     IP                        Name
02.02.2016       192.168.0.124        user3
02.02.2016       192.168.0.15          user2
...
03.02.2016       192.168.0.162        user1

and this is source code:

sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,"1.xls");
      TRY
    {
        // trying to open database using DSN
     base.Open(NULL,false,false,sDsn);
        // memory allocation
        CRecordset recset( &base);

sSql = "SELECT IP FROM [Sheet1$] GROUP BY IP";

        recset.Open(CRecordset::forwardOnly,sSql,CRecordset::readOnly);

            while( !recset.IsEOF())
        {
            recset.GetFieldValue("IP",temp2);
                        recset.MoveNext();

        }

            recset.Close();

            base.Close();

But if I try to change some rows in my original Excel book, for example -

--------*Excel book*--------------
----------02/12/2016--------------
date                     IP                        Name
02.02.2016       192.168.0.124        user3
02.02.2016       192.168.0.15          user2
...
03.02.2016       192.168.0.162        user1

my program can't read headers in this file (date, IP, etc). How can I make possible to read data from necessary fields? In my case - I need to read from A3 (not from A1 by default). Thank you for support.

                                            

how to add the object computer when debug the kernel driver?

$
0
0
i set the enviroment step by step acoording to the support website. But when i do the "adding new deivce", the edit box of(below) the "network host name" is missing and the "next" button is disabled. it's strange and someone could tell me why. thanks very much.

Win Api Question

$
0
0

Let's say you have complied an app1.exe which is an Win api program that opens up a simple window. And there is a app2.exe which opens an window also starts a short video on startup for example. Now what I want to accomplish is when I start app1.exe it launches app2.exe in the app1.exe window. So basically both opens windows right? But I want that app1.exe is the only window that should open, but executes app2.exe in app1.exe and instead of app2.exe open its own window and play the short video, it will play its video, but in the app1.exe window. How can this be done in C++ Win app?

Find Runtime Library mismatch

$
0
0

Hi.

i have a project that uses several libraries. At linking time I'm having problems regarding some mismatch of Runtime Library option in the libraries. 

How can I tell how every library was compiled (MD or MT)?

thank you

MSVCR120.dll is missing on many machines despite having Visual Studio 2010 and Visual Studio 2013 redistributables installed

$
0
0

Hi,

We have Visual Studio 2010 and Visual Studio 2013 redistributables installed on all our machines(x86 versions for 32 bit and x64 for 64 bit). Despite having this many of the machines ( not all of them ) do not have msvcr120.dll. I am at a loss to find out why is this particular dll is missing despite having the redistributables.

One possible ( and obvious ) solution is to download the missing dll. But since this is a time consuming and cumbersome task i would like to find out if there is any Hotfix for this issue or some workaround to get about the issue?

Request for your kind help.

What is the Windows Input Device for my keyboard?

$
0
0

I want to read from my Keyboard-Input-Device (Win32 Device Namespaces, \\.\). How can I decide which device is responsible for my keyboard. I can browse the available devices with the tool WinObj but I can not decide which device is the correct one.

I found an example where the device for input can be read/open with the function C++ function CreateFile("\\\\.\\interception00", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL).

On my PC there is no interception-device aviable. I looked with WinObj on an other PC and there were 20 interception-devices aviable. Why are these interception-devices not aviable on my PC ?

__imp__iob and legacy_stdio_definitions.lib

$
0
0

I am building an application that uses Sentinel Pro, and I have a problem getting the Sentinel Pro spromeps.lib to link with the CRT under Visual Studio 2015. The application builds successfully with Visual Studio 2012.

Using the legacy_stdio_definitions.lib has resolved most issues, but I still have one unresolved symbol, __imp__iob.

Will  legacy_stdio_definitions.lib be updated to include the __imp__iob symbol? And if so, when?

Viewing all 15302 articles
Browse latest View live


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