[prev in list] [next in list] [prev in thread] [next in thread]
List: ms-cryptoapi
Subject: Re: Newbie question
From: "Arrebola, Fabio" <fabio () CITTO ! COM ! BR>
Date: 2003-12-30 10:56:19
Message-ID: 002601c3cec3$8e640510$0ea0000a () porche
[Download RAW message or body]
Hi !
Here it goes ...
//+-------------------------------------------------------------------------
----------------------------
// First you'll need some defines ...
// This flags can be combined in order to hide the selected columns of the
select box
//--------------------------------------------------------------------------
----------------------------
#define CRYPTUI_SELECT_ISSUED_TO 0x00000001
#define CRYPTUI_SELECT_ISSUED_BY 0x00000002
#define CRYPTUI_SELECT_INTENDED_USE 0x00000004
#define CRYPTUI_SELECT_FRIENDLY_NAME 0x00000008
#define CRYPTUI_SELECT_LOCATION 0x00000010
#define CRYPTUI_SELECT_EXPIRATION_DATE 0x00000020
//+-------------------------------------------------------------------------
----------------------------
// Then you'll need callbacks ..
//--------------------------------------------------------------------------
----------------------------
typedef BOOL (WINAPI * SELECT_CERT_FILTER_CB_FN)(PCCERT_CONTEXT pCert,VOID
*Unknown,VOID *Userdata);
typedef VOID* (WINAPI * SELECT_CERT_CUSTOM_PAGES_CB_FN)(PCCERT_CONTEXT
pCert,VOID *Unknown,VOID *Userdata);
//+-------------------------------------------------------------------------
----------------------------
// Now ... it's necessary to have the structure that is going to be passed
to the function ...
// Don't forget .. one struct for UNICODE (using wide chars) and other to
ANSI ...
//--------------------------------------------------------------------------
----------------------------
typedef struct _SELECT_CERT_A {
DWORD dwSize;
HWND hWnd;
DWORD dwFlags;
LPCSTR szCaption;
DWORD dwHideColumn;
LPCSTR szMessage;
SELECT_CERT_FILTER_CB_FN FilterCallback;
SELECT_CERT_CUSTOM_PAGES_CB_FN CustomizeCallBack;
VOID* pUserCallBackData;
DWORD cStore;
HCERTSTORE *rghStore;
DWORD cAdditionalStore;
HCERTSTORE *rghAdditionalStore;
DWORD dwUnknown;
HCERTSTORE hMultiSelectStore;
} SELECT_CERT_A, *PSELECT_CERT_A;
typedef struct _SELECT_CERT_W {
DWORD dwSize;
HWND hWnd;
DWORD dwFlags;
LPWSTR szCaption;
DWORD dwHideColumn;
LPWSTR szMessage;
SELECT_CERT_FILTER_CB_FN FilterCallback;
SELECT_CERT_CUSTOM_PAGES_CB_FN CustomizeCallBack;
VOID* pUserCallBackData;
DWORD cStore;
HCERTSTORE *rghStore;
DWORD cAdditionalStore;
HCERTSTORE *rghAdditionalStore;
DWORD dwUnknown;
HCERTSTORE hMultiSelectStore;
} SELECT_CERT_W, *PSELECT_CERT_W;
//+-------------------------------------------------------------------------
----------------------------
// Finally the function ...
//--------------------------------------------------------------------------
----------------------------
WINCRYPT32API PCCERT_CONTEXT WINAPI
CryptUIDlgSelectCertificateA(SELECT_CERT_A*);
WINCRYPT32API PCCERT_CONTEXT WINAPI
CryptUIDlgSelectCertificateW(SELECT_CERT_W*);
#ifdef UNICODE
#define SELECT_CERT SELECT_CERT_W
#define PSELECT_CERT PSELECT_CERT_W
#define CryptUIDlgSelectCertificate CryptUIDlgSelectCertificateW
#else
#define SELECT_CERT SELECT_CERT_A
#define PSELECT_CERT PSELECT_CERT_A
#define CryptUIDlgSelectCertificate CryptUIDlgSelectCertificateA
#endif
//+-------------------------------------------------------------------------
----------------------------
// Using the function ...
//--------------------------------------------------------------------------
----------------------------
SELECT_CERT sc_st;
VIEW_CERT vc_st;
PCCERT_CONTEXT pCert;
HCERTSTORE hStore;
hStore = CertOpenSystemStore(0, "MY");
// ... etc, etc
sc_st.dwSize = sizeof(sc_st);
sc_st.hWnd = 0;
sc_st.dwFlags = 0; // here is where you can use the "HIDE" flags
sc_st.szCaption = "Certificate Selection";
sc_st.dwHideColumn = 0;
sc_st.szMessage = "Select the certificate you wish to use.";
sc_st.FilterCallback = 0;
sc_st.CustomizeCallBack = 0;
sc_st.pUserCallBackData = 0;
sc_st.cStore = 1;
sc_st.rghStore = &hStore;
sc_st.cAdditionalStore = 0;
sc_st.rghAdditionalStore = 0;
sc_st.dwUnknown =0;
sc_st.hMultiSelectStore = 0;
again:
if (((pCert = CryptUIDlgSelectCertificate(&sc_st)) == NULL)) {
// etc, etc
goto again; // win2K has this control already built in
}
// etc, etc
if (pCert)
CertFreeCertificateContext(pCert);
if (hStore)
CertCloseStore(hStore, 0);
Don't forget the cryptui lib !
Hope it helps !
Arrebola, Fabio
----- Original Message -----
From: "Ng Tze Yang" <ngtzeyang@KUALA-LUMPUR.SEMA.SLB.COM>
To: <CryptoAPI@DISCUSS.MICROSOFT.COM>
Sent: Tuesday, December 30, 2003 3:46 AM
Subject: Re: Newbie question
> Hi,
>
> Do you have some doc on the not formal doc API
CryptUIDlgSelectCertificate?
> If you have more not formal doc API list will be grateful that you can
> share it with me. thanks.
>
> regards,
> Tze Yang
>
> ----------------------------------------------------------------
> Users Guide http://discuss.microsoft.com/archives/mailfaq.html
> contains important info. Save time, search the archives at
> http://discuss.microsoft.com/archives/index.html .
> To unsubscribe, mailto:CryptoAPI-signoff-request@DISCUSS.MICROSOFT.COM
----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.html
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:CryptoAPI-signoff-request@DISCUSS.MICROSOFT.COM
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic