I'm trying to use a method defined in the Windows Media Format SDK (wmsdkidl.h) - virtual HRESULT STDMETHODCALLTYPE AcquireCredentials(
-
/* [in] */ WCHAR *pwszRealm,
-
/* [in] */ WCHAR *pwszSite,
-
/* [size_is][out] */ WCHAR *pwszUser,
-
/* [in] */ DWORD cchUser,
-
/* [size_is][out] */ WCHAR *pwszPassword,
-
/* [in] */ DWORD cchPassword,
-
/* [in] */ HRESULT hrStatus,
-
/* [out] */ DWORD *pdwFlags) = 0;
In C++ I have some sample code that actually implements this and it's working - HRESULT CNetWrite::AcquireCredentials( WCHAR *pwszRealm,
-
WCHAR *pwszSite,
-
WCHAR *pwszUser,
-
DWORD cchUser,
-
WCHAR *pwszPassword,
-
DWORD cchPassword,
-
HRESULT hrStatus,
-
DWORD *pdwFlags )
-
{
-
HRESULT hr = S_OK;
-
-
WCHAR *wszUser = NULL;
-
WCHAR *wszPassword = NULL;
-
-
hr = ConvertTCharToWChar2( "MyUsername", &wszUser );
-
hr = ConvertTCharToWChar2( "MyPassword", &wszPassword );
-
-
wcscpy(pwszUser, wszUser);
-
wcscpy(pwszPassword, wszPassword);
-
-
(*pdwFlags) = 0x00;
-
-
SAFE_ARRAYDELETE( wszUser );
-
SAFE_ARRAYDELETE( wszPassword );
-
-
return S_OK;
-
}
But I cannot get it to work in C#. Until now, I have the following definition - [ComImport]
-
[Guid("342e0eb7-e651-450c-975b-2ace2c90c48e")]
-
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
-
public interface IWMCredentialCallback
-
{
-
void AcquireCredentials(
-
[In, MarshalAs(UnmanagedType.LPWStr)] string bstrRealm,
-
[In, MarshalAs(UnmanagedType.LPWStr)] string bstrSite,
-
[In, Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwszUser,
-
[In] uint cchUser,
-
[In, Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwszPassword,
-
[In] uint cchPassword,
-
[In] IntPtr hrStatus,
-
[In, Out] uint pdwFlags);
-
}
with the following implementation - public void AcquireCredentials(string bstrRealm, string bstrSite, StringBuilder pwszUser, uint cchUser, StringBuilder pwszPassword, uint cchPassword, IntPtr hrStatus, uint pdwFlags)
-
{
-
pwszUser = new StringBuilder("MyUsername");
-
pwszPassword = new StringBuilder("MyPassword");
-
-
pdwFlags = 0x00;
-
}
Can somebody help me make this method work in C#?
0 838 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Gabe Covert |
last post by:
I'm a new C# developer, and am developing an application which will utilize
a COM library from a third party. I have two following SDK calls from the
3rd-party SDK which I can't get to work under...
|
by: Eirik Eldorsen |
last post by:
I'm tring to translate an VB.NET method into C#. Here is what I've done so
far. Need help on the while loop
public static void SetInitialFocus(Control ctrl)
{
StringBuilder s = new...
|
by: Patrick Sullivan |
last post by:
I want to use this algorithm but can't figure it out, I never used BASIC. I
tried translating it but got lost in the gosubs and "for i - 1 to ...
nexts". I have figured out that FNU(X) is degree...
|
by: kboek |
last post by:
I'm trying to use a method defined in the Windows Media Format SDK (wmsdkidl.h)virtual HRESULT STDMETHODCALLTYPE AcquireCredentials(
/* */ WCHAR *pwszRealm,
/* */ WCHAR...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |