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

Retrieving event logs for non-english Windows editions

$
0
0

Retrieving event logs is relatively easy. The following is C#, but please pretend it is C++. You can see what it's doing anyway:

EventRecord Event = new EventLogReader
                      ( new EventLogQuery
                          ( "Microsoft-Windows-Time-Service/Operational",
                            PathType.LogName,"*"
                          )
                      ).ReadEvent();

What this does is returning the log entries in "Applications and Services Logs" / Microsoft / Windows / Time-Service / Operational. This works fine in English version of updated Windows 10. I am getting very strong indications that this does not work for non-English Windows, although I am not completely sure. The reason, I guess, is that the event log's path labelling would be in local language. Therefore, the string in the code would be invalid.

Can anyone see a language-agnostic way to retrieve those log entries? Thanks.



Code not transferring zip file

$
0
0

We are trying to compile files and upload the file as zip format to a vendors site through the URL and credentials provided by them. The URL and credentials are in the script. But the file transfer does not occur. We are running this through task scheduler on a Windows Server 2012 R2 server. There are no firewall configured for outbound or inbound. Firewall is disabled on the server.

They have an url which has /api/2/batch/profile. If I go directly to that path it gives me a 404 file not found. I added restapi/2/batch/profile and I get the following error. Server Error

404 - File or directory not found.
The resource you are looking for might have been removed, had its name 
changed, or is temporarily unavailable.

This is the script file (few lines from the main script)

---------<add key="ZippedFile" value="filename.zip" />
-------- <add key="EmailHost" value="smtp.company.com" />
----------<add key="EmailPort" value="25" />
---------<add key="DateAuditsBeganInPD" value="2012-03-18" />
----------<add key="WebServiceURI" 
----------value="https://companyname.com/api/2/batch/profile"/>
----------<add key="UserId" value="userID"/>
--------- <add key="Password" value="password"/>
--------- <add key="UploadResponseFile" value="UploadResponse.txt"/>
-------</appSettings>

I get no error message. The file does not get uploaded to their website. But, if we do it through CURL command and try to upload the file just through CURL command it uploads it from that server or from any desktop.

curl.exe -X POST -u "userID":"password" -H "content-type: multipart/form- 
data" --form "batch-file=@\\path to the zip file\filename.zip" --url "https://companyname.com/api/2/batch/profile"


AA2913


How to use AssemblyInfo.cpp

$
0
0
What is the AssemblyInfo.cpp file for? I though it was to set information about the exe file like Author, Company etc..

 

[assembly:AssemblyTitleAttribute("MyApp")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("")];
[assembly:AssemblyProductAttribute("App")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) 2009")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];

 

 

 



 but I've changed these values in strings and recompiled project. But in .exe file Properties thre is no information which i typed in AssemblyInfo.cpp. I know how to change them using resource file but what is AssemblyInfo.cpp for then? How to edit this file to get results?

 

CMFCToolBarComboBoxButton() With RGB Colors or ColorRef

$
0
0

All,

I have a Serialized (IMPLEMENT_SERIAL) CMFCToolBarComboBoxButton derived class that functions just fine by index. I would like to set the background color of each index either with a ColorRef or RGB. I have a ComboBox Class that does this but I cannot figure out how to combine the 2 so the CMFCToolBarComboBoxButton takes on the characteristics of My Combo Box. Any Help would be wonderful.

uninit_member: Non-static class member m_eErVerificationType is not initialized in this constructor nor in any functions that it calls.

$
0
0

Hello all,

I am getting the below warning message at the ErVerificationJob constructor

Uninitialized scalar field (UNINIT_CTOR)
uninit_member: Non-static class member m_eErVerificationType is not initialized in this constructor nor in any functions that it calls.

ErVerificationJob::ErVerificationJob()
{

}

Below is the complete code:

ErVerificationJob.h

namespace ErVerification
{
class ErVerificationJob : public ErJobBase
{
private:
ErVerificationUtils::ErVerificationType m_eErVerificationType;

public:
ErVerificationJob();
~ErVerificationJob();

};
}

ErVerificationJob.cpp

ErVerificationJob::ErVerificationJob()
{

}

ErVerificationJobUtils.h

namespace ErVerificationUtils
{
enum ErVerificationType
{
PREINSTALL = 1,
POSTINSTALL = 2
};
}

Could anyone please help me how to resolve this warning?

Code analyser

$
0
0
How can we prevent building of project if there is warnings using code analyzer.like fxcop

uninit_member: Non-static class member m_eErVerificationType is not initialized in this constructor nor in any functions that it calls.

$
0
0

Hello all,

I am getting the below warning message at the ErVerificationJob constructor

Uninitialized scalar field (UNINIT_CTOR)
uninit_member: Non-static class member m_eErVerificationType is not initialized in this constructor nor in any functions that it calls.

ErVerificationJob::ErVerificationJob()
{

}

Below is the complete code:

ErVerificationJob.h

namespace ErVerification
{
class ErVerificationJob : public ErJobBase
{
private:
ErVerificationUtils::ErVerificationType m_eErVerificationType;

public:
ErVerificationJob();
~ErVerificationJob();

};
}

ErVerificationJob.cpp

ErVerificationJob::ErVerificationJob()
{

}

ErVerificationJobUtils.h

namespace ErVerificationUtils
{
enum ErVerificationType
{
PREINSTALL = 1,
POSTINSTALL = 2
};
}

Could anyone please help me how to resolve this warning?

how to create/open/save a file as UTF-8 encoding in c++ using ofstream

$
0
0

Hi,

Our report should contains only ANSI strings.. but encoding should be 'UTF-8'.

i am using visual studio 2013 (win32) and my code is,

   std::ofstream of;

   of.open("d:/abcdef.txt", std::ios::out | std::ios::app);

   std::locale utf8_locale(std::locale(), new utf8cvt<false>);

   of.imbue(utf8_locale);

   of << "my sample strings";

   of.close();

with this code i have compilation error on locale (no instance of constructor matches the argument list.

argument types are: (std::locale, <error-type>))

anyone please help me 

regards,

Midhun


0x0000000B | ASCII

$
0
0

0x0000000B - Error Code | Explain What is this actually?

ASCII - UNICODE | What is this? 


passing a safeArray of rank 3 from ATL object to c#

$
0
0

I have defined a function in my c++ ActiveX object that fills and returns a safeArray of rank 3.

The length of the Array is not known in c# when calling the function.

In the idl of my c++ ActiveX object, I defined the function like so:

HRESULT Read ([in, out] SAFEARRAY(short)* ppBuffer, [out, retval] long* pReturn);

The c++ code defines an array of rank 3 and fills this array with my data:

STDMETHODIMP CIstFileAccess::Read(SAFEARRAY** ppBuffer,  long* pReturn)
{
 SAFEARRAYBOUND boundsArray[3]; // Three dimensions
 ...
// setup bounds
 ...
 SAFEARRAY FAR* pMySafeArray = SafeArrayCreate(VT_I2, 3, boundsArray);
 short* lpBuffer = NULL; 
 hrRetVal = SafeArrayAccessData(pMySafeArray, (void**)&lpBuffer);
 ...
// Fill lpBuffer with valid data
 ...
 SafeArrayUnaccessData(pMySafeArray);
 *ppBuffer = pMySafeArray;

 *pReturn = 0;

}

Our old VB6 code called this function using a variable of type:

DIM buffer[] as integer

After calling our interface in VB6, the buffer was propperly filled with an array of rank 3.

In C# this function represents as:

int interfaceClass.Read ( ref short[] ppBuffer );

calling it like so:

short[] buffer = null;
int ret = interfaceClass.Read ( ref  ppBuffer );

throws an exception:
"A SafeArray of rank 3 was passed to a method, that expects an array of rank 1"

So my question:
What do I have to do, to be able to call this function propperly from C# ?

CreateProcessAsUserW & cmd.exe not start

$
0
0

Hi to all,

I have a problem with the CreateProcessAsUserW function called from a service that run as  Local System on a terminal server. 

If I run the following snippet the regedit.exe will be execute correctly on the desktop of the user:

char text[] = "C:\\windows\\regedit.exe";
wchar_t wtext[MAX_PATH];
std::mbstowcs(wtext, text, strlen(text)+1);
LPWSTR ptr = wtext;

// Start the process on behalf of the current user
BOOL result = CreateProcessAsUserW( hUserToken,
NULL,
ptr,
NULL,
NULL,
FALSE,/* On Terminal Server MUST be FALSE */
/*CREATE_NO_WINDOW*/ CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS | CREATE_UNICODE_ENVIRONMENT,
lpEnvironment,
NULL,
&StartupInfo,
&ProcessInfo);

Bui if I change the command line:

char text[] = "C:\\windows\\system32\\cmd.exe /C C:\\runner\\launch.bat";

I see a black windows for a fraction of second but  the batch doesn't start. The launch.bat contains only a pause command.

The GetExitCodeProcess reports :[1]

The same result with:

char text[] = "C:\\windows\\system32\\cmd.exe";

Help please.

Thanks

Problem with open header on click

$
0
0

I have Visual 2019 16.3.8

When I click on #include (my headeri project) ,

1. header open at right like not project file

2. syntax highlights colors are odd: comments are not highlighted

3. sometimes is error and ask me log: C:\Users\Andrzej\AppData\Roaming\Microsoft\VisualStudio\16.0_f93ee2bd\ActivityLog.xml

BuildCustomizations

$
0
0

Why is it different again???

2015 and earlier... well, we don't have to talk about this.

2017 -> ..\Common7\IDE\VC\VCTargets\BuildCustomizations

2019 -> ..\MSBuild\Microsoft\VC\v150\BuildCustomizations and ..\MSBuild\Microsoft\VC\v160\BuildCustomizations

... I need to build a setup to install such customizations. Now... how can I find those paths at runtime and why do we have 2 directories in 2019? And why is it changing with EVERY Visual Studio version?

Or... can we finally (in 2017 this doesn't work... yes, I have tried it) install BuildCustomizations via the Extensions directory? (no, I haven't tried it for 2019)

Rudolf

why is WM_SIZE handled before WM_DISPLAYCHANGE when the monitor's scale factor or resolution or position is changed?

$
0
0
Hello everyone, in my application, when the monitor's scale factor or resolution or position is changed, the message WM_DISPLAYCHANGE is generated, and the message can be handled with the macro MESSAGE_HANDLER. However, there is also a function deals with the message WM_SIZE, and this message is always handled before WM_DISPLAYCHANGE, why? And is there a way to handle WM_DISPLAYCHANGE first?

which part of the code do I need to place in the catch block to handle the exception?

$
0
0

Hello All,

From the below function, when executing waitParam.SetValue(true); it is throwing an exception from ~TypeValue() destructor.

To catch the exception, I have used try/catch but it is not handling the exception. Which part of the code do I need to place in the catch block to handle the exception?


I have fixed the issue by changing

if (mStringVal)

with

if (mKind == pkString && mStringVal != nullptr)

in ~TypeValue() destructor.

But wanted to know which part of the code do I need to place in the catch block to handle the exception?

~TypeValue()
{
if (mKind == pkString && mStringVal != nullptr)
{
delete mStringVal;
mStringVal = nullptr;
}
};

Below is the complete code:

int PCPEAutomation::Execute()
{
std::wstring strFilePath = L"C:\PCPEAutomationDev\src\AutomationFiles";
DWORD dwResult = ERROR_SUCCESS;
try
{
PCPECLIAutomation pcpeCLIAutomation;

// Set working dir param
Parameter workingDirParam(PARAMETER_WORKING_DIR);
workingDirParam.SetValue(strFilePath);
pcpeCLIAutomation.SetParameter(workingDirParam);

// Set wait flag param
Parameter waitParam(PARAMETER_WAIT_FOR_COMPLETE);
waitParam.SetValue(true);
pcpeCLIAutomation.SetParameter(waitParam);

//Execute the CLI operation
m_nStatus = pcpeCLIAutomation.Execute();
}
catch (...)
{
dwResult = ERROR_UNHANDLED_EXCEPTION;
}
return m_nStatus;
}

Parameter.h

#include "TypeValue.h"

class Parameter
{
private:
std::wstring mID;
TypeValue mValue;
public:
Parameter()
{
}
Parameter(std::wstring id) :
mID(id)
{
}
~Parameter()
{

}
bool SetValue(const PropertyValue& value)
{
mValue = value;
return true;
}
bool GetValue(PropertyValue& value)const
{
value = mValue;
return true;
}
std::wstring GetID() const
{
return mID;
}
};

TypeValue.h

enum TypeValueKind
{
pkEmpty = 0,
pkBool = 1,
pkInt = 2,
pkString = 3
};

class TypeValue
{
private:
union
{
boolmBoolVal;
intmIntVal;
std::wstring *mStringVal;
};

TypeValueKind mKind;

public:
typedef std::vector<TypeValue*> ArrayVal;

TypeValue() : mKind(pkEmpty)
{
mBoolVal = false;
mIntVal = 0;
mStringVal = nullptr;
};

~TypeValue()
{
if (mStringVal)
{
delete mStringVal;
mStringVal = nullptr;
}
};

TypeValue(bool val) : mKind(pkBool)
{
mBoolVal = val;
}

TypeValue(int val) : mKind(pkInt)
{
mIntVal = val;
}

TypeValue(std::wstring &val) : mKind(pkString)
{
mStringVal = new std::wstring();
*mStringVal = val;
}
};

Could anyone please help me on this?


XSD : error : The CodeDom provider type "Microsoft.VisualC.CppCodeProvider, CppCodeProvider could not be located.

$
0
0

I'm moving to a new development machine and after installing Visual Studio 2017 I've got the error

XSD : error : The CodeDom provider type "Microsoft.VisualC.CppCodeProvider, CppCodeProvider, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" could not be located.

When working with some XSD files.

I have exactly the same Visual Studio 2017 installation in both machines, but the new one is not able to "xseed" the files due that error. 

The only difference in both machines is the old one had other older Visual Studio versions installed and now removed.

Any idea how to resolve this?


EnumFontFamilies documentation

$
0
0

Hi, ALL,

On the page https://docs.microsoft.com/en-us/previous-versions/dd162618(v=vs.85)#parameters, the 3rd parameter can be given a value of DEVICE_FONTTYPE, RASTER_FONTTYPE or TRUETYPE_FONTTYPE.

However in the "Remarks" section the documentation talks about OpenType and TrueType fonts.

Does this mean that there is an undocumented OPENTYPE_FONTTYPE constant defined somewhere? Or OpenType fonts are returned under TRUETYPE_FONTTYPE?

Is there a way to differentiate them?

Could someone please clarify?

Thank you.

GetWindowTextA does not exist?

$
0
0

Hello

I try to compile a private project a person gave me years ago but it does not seems to work with VS 2019. He told me he compiled with VS2015 with old build tools v141

Can anyone help me with it? I don't have contact to the person anymore

Error (active)E0289no instance of constructor "ATL::CW2AEX<t_nBufferLength>::CW2AEX [with t_nBufferLength=128]" matches the argument listxxxD:\xxx193
Error (active)E0135class "CEdit" has no member "GetWindowTextA"xxxD:\xxx165
ErrorC2664 'ATL::CW2AEX<128>::CW2AEX(const ATL::CW2AEX<128> &) throw()': cannot convert argument 1 from 'CStringA' to 'LPCWSTR'xxxD:\xxx193
ErrorC2039 'GetWindowTextA': is not a member of 'CEdit' xxxD:\xxx 165



I'm having a problem trying to run my first x64 assembly in VS2017 v 15.9.17

$
0
0

I'm following the instructions given in this answer in Stackoverflow. But when I press CTRL+F5 I get the following error:

error LNK2001: unresolved external symbol mainCRTStartup

Please take a look at the printscreen in my OneDrive. 

run masm on mac

$
0
0
i want to run masm on mac including irvine library ,is it possible using visual studio 2019? if not,then recommend some app to run my required program.
Viewing all 15302 articles
Browse latest View live


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