please dont rip this site Prev Next

CryptSetProvider info  Overview  Group

The CryptSetProvider function is used to specify the current user default CSP.

After this function has been called, any calls this user subsequently makes to CryptAcquireContext specifying the dwProvType provider type but not a provider name, will result in the pszProvName provider being used.

Note  Typical applications will not use this function. It is intended for sole use by administrative applications.

BOOL CRYPTFUNC CryptSetProvider(

    LPCTSTR pszProvName,

    DWORD dwProvType

   );

Parameters

pszProvName
[in] The name of the new default CSP. This CSP should have already been installed on the computer.
dwProvType
[in] The provider type of the CSP specified by the pszProvName parameter.

Remarks

Well-behaved applications do not usually specify a CSP name when calling the CryptAcquireContext function. This gives the users a certain amount of freedom in that they can select a CSP that has an appropriate level of security.

This means that a call to CryptSetProvider will often determine the CSP of a given type used by all applications that run from that point on. With this being the case, the CryptSetProvider function should never be called without the user’s consent.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To retrieve extended error information, use the GetLastError function.

The following table lists the error codes most commonly returned by the GetLastError function.

Error

Description

ERROR_INVALID_HANDLE

One of the parameters specifies an invalid handle.

ERROR_INVALID_PARAMETER

One of the parameters contains an invalid value. This is most often an illegal pointer.

ERROR_NOT_ENOUGH_MEMORY

The operating system ran out of memory during the operation.

Error codes returned from the RegCreateKeyEx function.

See RegCreateKeyEx.

Error codes returned from the RegSetValueEx function.

See RegSetValueEx.

Example

HCRYPTPROV hProv = 0;



// Specify the default PROV_RSA_SIG provider. Note that this assumes

// that a CSP with a type of PROV_RSA_SIG and named "Joe's Provider"

// has already been installed.

if(!CryptSetProvider(TEXT("Joe's Provider"), PROV_RSA_SIG)) {

    printf("Error %x during CryptSetProvider!\n", GetLastError());

    return;

}



// Get handle to the provider that we just made default.

if(!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_SIG, 0)) {

    printf("Error %x during CryptAcquireContext!\n", GetLastError());

    return;

}



...



// Release provider handle.

if(!CryptReleaseContext(hProv, 0)) {

    printf("Error %x during CryptReleaseContext!\n", GetLastError());

    return;

}

 

See Also

CryptAcquireContext 


file: /Techref/os/win/api/win32/func/src/f12_17.htm, 5KB, , updated: 2000/4/7 11:19, local time: 2024/11/27 13:26,
TOP NEW HELP FIND: 
18.118.146.180:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/techref/os/win/api/win32/func/src/f12_17.htm"> CryptSetProvider Release 2]</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .