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

`export` attribute not found

$
0
0

Hello,

After upgrading the compiler to v141, i am unable to use the COM c++ attribute `export`.

The compiler throws error saying - error C2337: 'export': attribute not found. Does this version of compiler not support this attribute at all ?

Thank-you for your time!


 



MFC control question?

$
0
0

Hi, I want to ask when using MFC, is there any 3rd party controller that supports it? eg syncfusion, telerik, ..
because I want to use more features and more modern for my project.
Currently I am only allowed to use MFC and WPF, but I do not know anything about wpf and how to link it to c ++.

Many thanks!


How do I put an image in a property value with CMFCPropertyGridProperty?

$
0
0
I want to put an image in the property value, not text.

Color boxes, files, etc. are supported by API, but images are not.

Please tell me how to do it.

Cannot Do mixed debugging in Visual Studio 2019 with MSVC 141

$
0
0

Hello,

We Have updated to Visual Studio 2019 from 2017, but we kept MSVC 141.

With Visual Studio 2017 we could step in our C++ code using mixed debugging from our managed code.

In Visual Studio 2019 this does not work any longer.

the list of loaded modules does not even show the dlls we want to debug.

Is it possible that we have to update to MSVC 142 so that mixed debugging will work in VS 2019?

Thx,

Hinrich


Unable rebuild solution in Visual Studio

$
0
0

Hi All,

The following error message is occurring again and again while rebuilding my VS-2019 solution since last Wednesday day. I have done all my possible troubleshoot at my end. However, issue still persist. Could you please help me on this?

1. Giving full access to solution folder 

2. Remove read-only access to the folder 

3. Disable security essentials/firewall 

4.Provide full access to the hard disk driver 

ErrorCS0009Metadata file 'E:\.............................ces.dll' could not be opened -- Access to the path 'E:\............................................ces.dll' is denied.

Thank you!

Static variable question?

$
0
0

hello, i want to ask if i do this right?
I think when declaring static in .h file
Then in .cpp I declare include .h, it will work as in one file.

however it does not seem to work! where i was wrong?

when i debug: The variable is not initialized

however in another similar project, it works. It seems to be possible due to the compiler structure (is this possible?)


Assigning multiple functions to the function pointer

$
0
0

In C#, we can assign multiple methods to the delegate using '+' operator.

In C++, is it possible to assign multiple functions to the function pointer?

If so, how to do it?

InputInjector in C++

$
0
0

I am trying to send keyboard inputs, similar to what sendkeys does in C++

From https://docs.microsoft.com/en-us/windows/uwp/design/input/input-injection, I can see C# code like this:

_inputInjector = InputInjector.TryCreate();

How can I do this in straight C++ instead of C#?


MFC Cdialog how to set text for listbox?

$
0
0
Hello, with the editbox I use setdlgitemtext to set text
But with listbox, which method should I use to set text?
In addition, a little silly I would like to ask more about Clistbox is the type of MFC dialog box, how is it different from listbox control?
thanks a lot!


Unexpected output from string concatenation.

$
0
0

I added the following code to my program.

string str;

str="00."+'0';

The '0' part was converted to a decimal number then added to str giving 00.48

I would have expected to get str="00.0".

In C# I do get 00.0.

Yes  I know I could use "00."+"0" but the compiler should have added strings or thrown up an error.


n.Wright



what is the correct/required headers to have for c++ code?

$
0
0

here is my c++code:

#include <set-location; ip address generator.exe location= C:\Users\yda\ip
using namespace std;
{

int main()
}
// Function checks whether IP digits
// are valid or not.
int is_valid(string ip)
{
    // Splitting by "."
    vector <string> ips;
    string ex = "";
    for(int i = 0; i < ip.size(); i++)
    {
        if (ip[i] == '.')
        {
            ips.push_back(ex);
            ex = "";
        }
        else
        {
            ex = ex + ip[i];
        }
    }
    ips.push_back(ex);
 
    // Checking for the corner cases
    // cout << ip << endl;
    for(int i = 0; i < ips.size(); i++)
    {
        // cout << ips[i] <<endl;
        if( ips[i].length() > 3 || 
            stoi(ips[i]) < 0 || 
            stoi(ips[i]) > 255 )
            return 0;
 
        if( ips[i].length() > 1 && 
            stoi(ips[i]) == 0)
            return 0;
 
        if( ips[i].length() > 1 && 
            stoi(ips[i]) != 0 && 
            ips[i][0] == '0')
            return 0;
    }
    return 1;
}
 
// Function converts string to IP address
void convert(string ip)
{
    int l = ip.length();
 
    // Check for string size
    if ( l>12 || l<4 )
    {
        cout << "Not Valid IP Address";
    }
 
    string check = ip;
    vector <string> ans;
 
    // Generating different combinations.
    for( int i = 1; i < l - 2; i++ )
    {
        for( int j = i + 1; j < l - 1; j++ )
        {
            for( int k = j + 1; k < l; k++ )
            {
                check = check.substr(0, k) + "." + 
                        check.substr(k, l - k + 2);
                check = check.substr(0, j) + "." + 
                        check.substr(j, l - j + 3);
                check = check.substr(0, i) + "." + 
                        check.substr(i, l - i + 4);
 
                // cout<< check <<endl;
                // Check for the validity of combination
                if (is_valid(check))
                {
                    ans.push_back (check);
                    std::cout << check << '\n';
                }
                check = ip;
            }
        }
    }
}
 
// Driver code
int main()
{
    string A = "25525511135";
    string B = "25505011535";
 
    convert(A);
    convert(B);
 
    return 0;
}

How to launch 'Tablet PC setting' option in C++

$
0
0

Hi,

I have requirement to launch the 'Tablet PC Setting' option through Programatically using C++ i have tried the below things but not working as expected:
Rundll32.exe Shell32.dll,Control_RunDLL TabletPC.cpl,,{80F3F1D5-FECA-45F3-BC32-752C152E456E}
but it is opening Pen and Touch windows but i wanted to open 'Tablet PC Settings' window where i get the calibrate option.

And also i have tried : 

BOOL bResult = CreateProcess(_T("C:\\Program Files\\Common Files\\microsoft shared\\ink\\TabTip.exe"),
NULL, ......)  in this case it is not even opening anything. 

It would be great if someone helps me out.

Thanks,

Project error LNK2005: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj)

$
0
0

hi to all

Actually i open a visual C++ 6.0 project on Visual C++.net and i got many errors and i resolve most of them but i cant resolve these two errors. these are the errors summary:

Project error LNK2005: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj)
Project fatal error LNK1169: one or more multiply defined symbols found

So please help in this regard it is urgent thing for me .

Thanks in Advance.

bye

Feasibility of writing a named pipe code in WIndows 10.

$
0
0

I think I need to set up named pipe for moving a stream of bytes across a solution to a different file. I just read this warning:

Windows 10, version 1709:  Pipes are only supported within an app-container; ie, from one UWP process to another UWP process that's part of the same app. Also, named pipes must use the syntax "\\.\pipe\LOCAL\" for the pipe name. 

My OS is Windows 10 Pro, Version 10.0.18362 Build 18362

Will I have any problems? And what's UWP? Universal Windows Platform? How will I find out if I have one or need one?

Thanks, - MyCatAlex


Pointer to Function Question **

$
0
0

Hi, I want to ask this problem: my code have a pointer scnf to function
<Do not edit the total sum function>

I want when the totalsum executes will call scnf with first parameter equal to pt1 (pt1 is entered by the user - it may change)
I tried to use

scnf = newSum;
scnf (pt1,5);

However this doesn't work? I think it is possible to use global variables, but is there a different solution?

int pt1=3

int (*scnf)(int pt, int mt);

scnf=newSum;  
scnf(pt1,5);

rc = Totalsum(  ssname,						
		L"Select number",	
		0,											
		scnf,									
		return_sum);

//---------------------------------------------

int newSum(int num1, int num2) {
	custom(num2); //custom function 	
	custom(num1)
	return 1; // 
}

Many thanks!



Gap in SECURITY_DESCRIPTOR structure (Revision, Cbz1)

$
0
0

If you look at the page with the description of the SECURITY_DESCRIPTOR structure you can see that a function to define "Revision" is missing, or am I missing something? If it is really missing, then how people use this structure? I really need it.

What is Cbz1? Another puzzle?

Thank you, - MyCatAlex





C4986 with STDMETHOD/IMP

$
0
0

Hi,

I'm getting a ton of C4986 warnings. The code in question uses the STDMETHOD macro in the header file and the STDMETHODIMP in the implementation file. I had a look at the definitions and as it turned out, STDMETHOD is defined with __declspec(nothrow) whereas STDMETHODIMP is not.

What is the reason for that? Is there an elegant way to get rid of the warnings in this particular case?

VS 16.4.5, SDK 10.0.18362.0

Rene


how do i get rid of the c++ error at line 14 char:12 An expression was expected after '('. ?

$
0
0
#include <iostream>
#include <string>
#include <vector>
using namespace std; 
{

int main()

// Function checks whether IP digits 
// are valid or not. 
int is_valid(string ip) 

    // Splitting by "." 
    vector <string> ips; (line 14, char 12)
    string ex = ""; 
    for(int i = 0; i < ip.size(); i++) 
    { 
        if (ip[i] == '.') 
        { 
            ips.push_back(ex); 
            ex = ""; 
        } 
            return true;
        { 
            ex = ex + ip[i]; 
        } 
    } 
    ips.push_back(ex); 
  
  
    // cout << ip << endl; 
    for(int i = 0; i < ips.size(); i++) 
    { 
        // cout << ips[i] <<endl; 
        if( ips[i].length() > 3 ||  
            stoi(ips[i]) < 0 ||  
            
        if( ips[i].length() > 1 &&  
            stoi(ips[i]) == 0) 
            return false; 
  
        
    } 
    

  


    int l = ip.length(); 
  
    // Check for string size 
    if ( l>12 || l<4 ) 
    { 
        cout << "Not Valid IP Address"; 
    } 
 int l = ip.length(); 
  
    // Check for string size 
    if ( l<12 || l<4 ) 
    { 
        cout << "Valid IP Address";
 
    string check = <vector string>; 
    vector <string> ans; 
  
    // Generating different combinations. 
                   int main()
    for( int i = 1; i < l - 2; i++ ) 
    { 
        for( int j = i + 1; j < l - 1; j++ ) 
        { 
            for( int k = j + 1; k < l; k++ ) 
            { 
                check = check.substr(0, k) + "." +  
                        check.substr(k, l - k + 2); 
                check = check.substr(0, j) + "." +  
                        check.substr(j, l - j + 3); 
                check = check.substr(0, i) + "." +  
                        check.substr(i, l - i + 4); 
  
                // cout<< check <<endl; 
                // Check for the validity of combination 
                if (is_valid(check)) 
 then the ip address are valid.
                { 
                    ans.push_back (check); 
                    std::cout << check << '\n'; 
                } 
                check = ip; 
            } 
        } 
    } 

  
// shows vallid ip addressess.
int main() 

    string A = "146.000.77.35"; 
    string B = "153.21.89.27"; 
  
    convert(A); 
    convert(B); 
  
    return valid ip address; 

  
echo // This code is contributed by neo123

how do i remove the error Missing file specification after redirection operator. At line:31 char:19 in powershell?

$
0
0

when I run my code it gives a error message at line 32 saying missing file specification after redirection operator.

I have added what i thought were missing Sile specification and got no where with it and i have looked into how to get rid of the problem and have got nowhere

the code that makes the error occur is / cout << ip << endl; how do I remove the error without removing the code?

Outlook profile - multiple message service for Exchange

$
0
0

Hello,

I don't have any experience in C++ and I need to create a console application to create one Outlook profile with two message service for Exchange

Why C++? Since Outlook 2016 PRF files are no more supported and Extended MAPI needs to be used

Found the following code on Microsoft Website

https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/how-to-programmatically-create-a-profile-in-outlook

I changed the code to include tow emails instead of one but having an issue with CreateMsgService

Basically the second message service is created but empty

Copied the code at the end of this message

Thank you for your help

Goksel 

// CreateProfile.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
#include <MAPIX.h>
#include <MAPIUtil.h>
#include <EdkMdb.h>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define PR_PROFILE_USER_SMTP_EMAIL_ADDRESS1 PROP_TAG(PT_TSTRING, pidProfileMin+0x41)
#define PR_PROFILE_USER_SMTP_EMAIL_ADDRESS1_W PROP_TAG(PT_UNICODE, pidProfileMin+0x41)
#define PR_PROFILE_USER_SMTP_EMAIL_ADDRESS2 PROP_TAG(PT_TSTRING, pidProfileMin+0x41)
#define PR_PROFILE_USER_SMTP_EMAIL_ADDRESS2_W PROP_TAG(PT_UNICODE, pidProfileMin+0x41)
#define PR_EMSMDB_SECTION_UIDPROP_TAG(PT_BINARY, 0x3D15)
#define MAPI_FORCE_ACCESS0x80000
STDMETHODIMP GetGlobalProfileSection(LPSERVICEADMIN lpSvcAdmin, LPMAPIUID lpMapiUid, ULONG ulFlags, LPPROFSECT * lppProfSect);
STDMETHODIMP GetEMSMDBVarProfileSection(LPSERVICEADMIN lpSvcAdmin, LPPROFSECT lpGlobalProfSection, LPPROFSECT * lppProfSect);
std::map<ULONG, LPWSTR> PropValueMap1
{
{
PR_DISPLAY_NAME_W,
L"MAILBOX1"
},
{
PR_PROFILE_USER_SMTP_EMAIL_ADDRESS1_W,
L"=SMTP:mailbox1@contoso.com"
}
};
std::map<ULONG, LPWSTR> PropValueMap2
{
{
PR_DISPLAY_NAME_W,
L"MAILBOX2"
},
{
PR_PROFILE_USER_SMTP_EMAIL_ADDRESS2_W,
L"=SMTP:mailbox2@contoso.com"
}
};
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hRes = S_OK;            // Result from MAPI calls.
LPPROFADMIN lpProfAdmin = NULL;     // Profile Admin object.
LPSERVICEADMINlpSvcAdmin = NULL;      // Service Admin object.
LPMAPITABLE lpMsgSvcTable = NULL;   // Table to hold services.
LPSRowSet lpSvcRows = NULL;       // Rowset to hold results of table query.
vector<SPropValue>rgvals;
SRestriction sres;                   // Restriction structure.
SPropValue SvcProps;               // Property structure for restriction.
LPPROFSECT lpGlobalProfSection = nullptr;
LPPROFSECT lpEmsMdbVarProfSect = nullptr;
SPropValue spvSmtpAddressW;
SPropValue spvDisplayName;
// This indicates columns we want returned from HrQueryAllRows.
enum { iSvcName, iSvcUID, cptaSvc };
SizedSPropTagArray(cptaSvc, sptCols) = { cptaSvc, PR_SERVICE_NAME, PR_SERVICE_UID };
string ProfileName = "SMS";
// Initialize MAPI.
if (FAILED(hRes = MAPIInitialize(NULL)))
{
cout << "Error initializing MAPI.";
goto error;
}
// Get an IProfAdmin interface.
if (FAILED(hRes = MAPIAdminProfiles(0,              // Flags.
&lpProfAdmin))) // Pointer to new IProfAdmin.
{
cout << "Error getting IProfAdmin interface.";
goto error;
}
// Create a new profile.
if (FAILED(hRes = lpProfAdmin->CreateProfile((LPTSTR)ProfileName.c_str(),     // Name of new profile.
nullptr,          // Password for profile.
0,          // Handle to parent window.
0)))        // Flags.
{
cout << "Error creating profile.";
goto error;
}
// Get an IMsgServiceAdmin interface off of the IProfAdmin interface.
if (FAILED(hRes = lpProfAdmin->AdminServices((LPTSTR)ProfileName.c_str(),     // Profile that we want to modify.
nullptr,          // Password for that profile.
0,          // Handle to parent window.
0,             // Flags.
&lpSvcAdmin))) // Pointer to new IMsgServiceAdmin.
{
cout << "Error getting IMsgServiceAdmin interface.";
goto error;
}
// Create the new message service for Exchange.
if (FAILED(hRes = lpSvcAdmin->CreateMsgService("MSEMS",     // Name of service from MAPISVC.INF.
NULL,        // Display name of service.
NULL,        // Handle to parent window.
NULL)))      // Flags.
{
cout << "Error creating Exchange message service.";
goto error;
}
// You now have to obtain the entry id for the new service.
// You can do this by getting the message service table
// and getting the entry that corresponds to the new service.
if (FAILED(hRes = lpSvcAdmin->GetMsgServiceTable(0,                 // Flags.
&lpMsgSvcTable)))  // Pointer to table.
{
cout << "Error getting Message Service Table.";
goto error;
}
// Set up restriction to query table.
sres.rt = RES_CONTENT;
sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING;
sres.res.resContent.ulPropTag = PR_SERVICE_NAME;
sres.res.resContent.lpProp = &SvcProps;
SvcProps.ulPropTag = PR_SERVICE_NAME;
SvcProps.Value.lpszA = "MSEMS";
// Query the table to obtain the entry for the newly created message service.
if (FAILED(hRes = HrQueryAllRows(lpMsgSvcTable,
(LPSPropTagArray)&sptCols,
&sres,
NULL,
0,
&lpSvcRows)))
{
cout << "Error querying table for new message service.";
goto error;
}
ZeroMemory(&spvSmtpAddressW, sizeof(spvSmtpAddressW));
spvSmtpAddressW.ulPropTag = PR_PROFILE_USER_SMTP_EMAIL_ADDRESS1_W;
spvSmtpAddressW.Value.lpszW = PropValueMap1[PR_PROFILE_USER_SMTP_EMAIL_ADDRESS1_W];
rgvals.push_back(spvSmtpAddressW);
if (FAILED(hRes = GetGlobalProfileSection(
lpSvcAdmin,
(LPMAPIUID)lpSvcRows->aRow->lpProps[iSvcUID].Value.bin.lpb,
MAPI_MODIFY,
&lpGlobalProfSection)))
{
cout << "Error attempting to get the Global Profile Section.";
goto error;
}
if (FAILED(hRes = lpGlobalProfSection->SetProps(
rgvals.size(),
rgvals.data(),
nullptr)))
{
cout << "Error attempting to set the smtp address.";
goto error;
}
if (FAILED(hRes = lpGlobalProfSection->SaveChanges(
KEEP_OPEN_READWRITE)))
{
cout << "Error attempting to save after setting the smtp address";
goto error;
}
if (FAILED(hRes = GetEMSMDBVarProfileSection(lpSvcAdmin, lpGlobalProfSection, &lpEmsMdbVarProfSect)))
{
goto error;
}
ZeroMemory(&spvDisplayName, sizeof(spvDisplayName));
spvDisplayName.ulPropTag = PR_DISPLAY_NAME_W;
spvDisplayName.Value.lpszW = PropValueMap1[PR_DISPLAY_NAME_W];
rgvals.push_back(spvDisplayName);
if (FAILED(hRes = lpEmsMdbVarProfSect->SetProps(
rgvals.size(),
rgvals.data(),
nullptr)))
{
cout << "Error call set props on the ems mdb var prof sect using the smtp address";
goto error;
}
if (FAILED(hRes = lpEmsMdbVarProfSect->SaveChanges(
KEEP_OPEN_READWRITE)))
{
cout << "Error attempting to save after setting the smtp address on the ems mdb var prof sect";
goto error;
}


// Create the new message service for Exchange.
if (FAILED(hRes = lpSvcAdmin->CreateMsgService("MSEMS",     // Name of service from MAPISVC.INF.
NULL,        // Display name of service.
NULL,        // Handle to parent window.
NULL)))      // Flags.
{
cout << "Error creating Exchange message service.";
goto error;
}

ZeroMemory(&spvSmtpAddressW, sizeof(spvSmtpAddressW));
spvSmtpAddressW.ulPropTag = PR_PROFILE_USER_SMTP_EMAIL_ADDRESS2_W;
spvSmtpAddressW.Value.lpszW = PropValueMap2[PR_PROFILE_USER_SMTP_EMAIL_ADDRESS2_W];
rgvals.push_back(spvSmtpAddressW);

if (FAILED(hRes = GetGlobalProfileSection(
lpSvcAdmin,
(LPMAPIUID)lpSvcRows->aRow->lpProps[iSvcUID].Value.bin.lpb,
MAPI_MODIFY,
&lpGlobalProfSection)))
{
cout << "Error attempting to get the Global Profile Section.";
goto error;
}
if (FAILED(hRes = lpGlobalProfSection->SetProps(
rgvals.size(),
rgvals.data(),
nullptr)))
{
cout << "Error attempting to set the smtp address.";
goto error;
}
if (FAILED(hRes = lpGlobalProfSection->SaveChanges(
KEEP_OPEN_READWRITE)))
{
cout << "Error attempting to save after setting the smtp address";
goto error;
}

if (FAILED(hRes = GetEMSMDBVarProfileSection(lpSvcAdmin, lpGlobalProfSection, &lpEmsMdbVarProfSect)))
{
goto error;
}
ZeroMemory(&spvDisplayName, sizeof(spvDisplayName));
spvDisplayName.ulPropTag = PR_DISPLAY_NAME_W;
spvDisplayName.Value.lpszW = PropValueMap2[PR_DISPLAY_NAME_W];
rgvals.push_back(spvDisplayName);
if (FAILED(hRes = lpEmsMdbVarProfSect->SetProps(
rgvals.size(),
rgvals.data(),
nullptr)))
{
cout << "Error call set props on the ems mdb var prof sect using the smtp address";
goto error;
}
if (FAILED(hRes = lpEmsMdbVarProfSect->SaveChanges(
KEEP_OPEN_READWRITE)))
{
cout << "Error attempting to save after setting the smtp address on the ems mdb var prof sect";
goto error;
}

cleanup:
// Clean up
if (lpEmsMdbVarProfSect) lpEmsMdbVarProfSect->Release();
if (lpGlobalProfSection) lpGlobalProfSection->Release();
if (lpSvcRows) FreeProws(lpSvcRows);
if (lpMsgSvcTable) lpMsgSvcTable->Release();
if (lpSvcAdmin) lpSvcAdmin->Release();
if (lpProfAdmin) lpProfAdmin->Release();
MAPIUninitialize();
return 0;
error:
cout << " hRes = 0x" << hex << hRes << dec << endl;
goto cleanup;
}
STDMETHODIMP GetGlobalProfileSection(LPSERVICEADMIN lpSvcAdmin, LPMAPIUID lpMapiUid, ULONG ulFlags, LPPROFSECT * lppProfSect)
{
HRESULT hRes = MAPI_E_CALL_FAILED;
LPPROFSECT lpProfSect = nullptr;
LPPROFSECT lpEmsMdbVarProfSect = nullptr;
ULONGcValues = 0;
LPSPropValue lpProps = nullptr;
SizedSPropTagArray(1, spta) = { 1,{ PR_EMSMDB_SECTION_UID } };
*lppProfSect = nullptr;
hRes = lpSvcAdmin->OpenProfileSection(lpMapiUid,
0,
MAPI_FORCE_ACCESS,
&lpProfSect);
if (FAILED(hRes) || lpProfSect == nullptr)
{
return hRes;
}
hRes = lpProfSect->GetProps((LPSPropTagArray)&spta, 0, &cValues, &lpProps);
if (FAILED(hRes) || lpProps == nullptr || cValues == 0)
{
return hRes;
}
if (lpProps[0].ulPropTag != PR_EMSMDB_SECTION_UID)
{
hRes = lpProps[0].Value.err;
goto Cleanup;
}
hRes = lpSvcAdmin->OpenProfileSection((LPMAPIUID)lpProps->Value.bin.lpb, 0, ulFlags, &lpEmsMdbVarProfSect);
if (FAILED(hRes) || lpEmsMdbVarProfSect == nullptr)
{
goto Cleanup;
}
*lppProfSect = lpEmsMdbVarProfSect;
Cleanup:
if (lpProps)
{
MAPIFreeBuffer(lpProps);
}
if (lpProfSect)
{
lpProfSect->Release();
}
return hRes;
}
STDMETHODIMP GetEMSMDBVarProfileSection(LPSERVICEADMIN lpSvcAdmin, LPPROFSECT lpGlobalProfSection, LPPROFSECT * lppProfSect)
{
HRESULT hRes = MAPI_E_CALL_FAILED;
SizedSPropTagArray(1, sptaStoreProviders) = { 1,{ PR_STORE_PROVIDERS } };
ULONGcValues = 0;
LPSPropValue lpProps = nullptr;
LPPROFSECT lpProfSect = nullptr;
if (!lpSvcAdmin || !lpGlobalProfSection || !lppProfSect)
return E_INVALIDARG;
*lppProfSect = nullptr;
if (FAILED(hRes = lpGlobalProfSection->GetProps(
(LPSPropTagArray)&sptaStoreProviders,
0,
&cValues,
&lpProps)) || cValues == 0 || lpProps == nullptr)
{
cout << "Error attempting to get the PR_STORE_PROVIDERS property " << endl;
goto Cleanup;
}
if (lpProps->ulPropTag != sptaStoreProviders.aulPropTag[0])
{
hRes = lpProps->Value.err;
goto Cleanup;
}
if (FAILED(hRes = lpSvcAdmin->OpenProfileSection(
(LPMAPIUID)lpProps->Value.bin.lpb,
0,
MAPI_FORCE_ACCESS | MAPI_MODIFY,
&lpProfSect)) || lpProfSect == nullptr)
{
cout << "Could not open the profile section using the PR_STORE_PROVIDERS property " << endl;
goto Cleanup;
}
*lppProfSect = lpProfSect;
Cleanup:
if (lpProps)
{
MAPIFreeBuffer(lpProps);
lpProps = nullptr;
}
return hRes;
}

Viewing all 15302 articles
Browse latest View live