Buenas, por si te sirve ayuda, te paso un c贸digo que muestra el di谩logo de selecci贸n de certificados de Windows y te devuelve el seleccionado:
#include "fivewin.ch"
func main()
聽 聽MsgInfo("Seleccionado certificado: "+ToTxt(SELCERT()), "CryptoApi")
return nil
//*****************************************************************************
//*****************************************************************************
function ToTxt( uVal )
聽 聽local cType := ValType( uVal )
聽 聽do case
聽 聽 聽 case cType == "C" .or. cType == "M"
聽 聽 聽 聽 聽 聽return uVal
聽 聽 聽 case cType == "D"
聽 聽 聽 聽 聽 聽return DToC( uVal )
聽 聽 聽 case cType == "L"
聽 聽 聽 聽 聽 聽return If( uVal, ".T.", ".F." )
聽 聽 聽 case cType == "N"
聽 聽 聽 聽 聽 聽return AllTrim( Str( uVal ) )
聽 聽 聽 case cType == "B"
聽 聽 聽 聽 聽 聽return "{|| ... }"
聽 聽 聽 case cType == "A"
聽 聽 聽 聽 聽 聽return "{ ... }"
聽 聽 聽 case cType == "O"
聽 聽 聽 聽 聽 聽return If( __ObjHasData( uVal, "cClassName" ), uVal:cClassName, uVal:ClassName() )
聽 聽 聽 case cType == "H"
聽 聽 聽 聽 聽 聽return "{=>}"
聽 聽 聽 otherwise
聽 聽 聽 聽 聽 聽return ""
聽 聽endcase
return nil
//*****************************************************************************
//*****************************************************************************
#pragma BEGINDUMP
#include <windows.h>
//#include <psapi.h>
//#include <hbapi.h>
//#include <hbapierr.h>
//#include <hbapiitm.h>
//#include <wincrypt.h>
#define CRYPTUI_SELECT_LOCATION_COLUMN 0x000000010
//Definir el prototipo de las funciones:
typedef HCERTSTORE (WINAPI * PTYPECERTOPEN) (HCRYPTPROV, LPTSTR);
typedef PCCERT_CONTEXT (WINAPI * PTYPECERTSELECTDLG) (HCERTSTORE, HWND, LPCWSTR, LPCWSTR, DWORD, DWORD, void*);
typedef PCCERT_CONTEXT (WINAPI * PTYPECERTENUM) (HCERTSTORE, PCCERT_CONTEXT);
typedef DWORD (WINAPI * PTYPECERTGETNAME) (PCCERT_CONTEXT, DWORD, DWORD, VOID*, LPTSTR, DWORD);
typedef DWORD (WINAPI * PTYPECERTNAMETOSTR) (DWORD, PCERT_NAME_BLOB, DWORD, LPTSTR, DWORD);
typedef BOOL (WINAPI * PTYPECERTFREECC) (PCCERT_CONTEXT);
typedef BOOL (WINAPI * PTYPECERTCLOSESTORE) (HCERTSTORE, DWORD);
HB_FUNC(SELCERT)
{
聽 聽// Hay varios ejemplos en: <!-- m --><a class="postlink" href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa382361(v=vs.85">https://msdn.microsoft.com/en-us/librar ... 61(v=vs.85</a><!-- m -->).aspx
聽 聽HCERTSTORE hStore;
聽 聽PCCERT_CONTEXT PrevContext, CurContext;
聽 聽PCHAR sNombre;
聽 聽DWORD cbSize;
聽 聽PHB_ITEM pArray;
聽 聽PHB_ITEM pItem;
聽 聽PCCERT_CONTEXT 聽 pCertContext;
聽 聽// Cargamos las librer铆as de las que queremos la direcci贸n de las funciones.
聽 聽HMODULE HCrypt = LoadLibrary("Crypt32.dll");
聽 聽HMODULE HCrypt2 = LoadLibrary("Cryptui.dll");
聽 聽// Declaramos el tipo de puntero a la funci贸n, tenemos la definici贸n arriba.
聽 聽PTYPECERTOPEN 聽 聽pCertOpen;
聽 聽PTYPECERTSELECTDLG 聽 聽pCertSelectDlg;
聽 聽PTYPECERTGETNAME pCertGetName;
聽 聽PTYPECERTNAMETOSTR pCertNameToStr;
聽 聽PTYPECERTFREECC pCertFreeCC;
聽 聽PTYPECERTCLOSESTORE pCertCloseStore;
聽 聽if (HCrypt != NULL && HCrypt2 != NULL){
聽 聽 聽 //Sacamos el puntero todas las funciones que vamos a usar mediante GetProcAddress:
聽 聽 聽 #ifdef UNICODE
聽 聽 聽 聽 聽pCertOpen 聽 聽= (PTYPECERTOPEN) GetProcAddress(HCrypt, "CertOpenSystemStoreW");
聽 聽 聽 聽 聽pCertGetName = (PTYPECERTGETNAME) GetProcAddress(HCrypt, "CertGetNameStringW");
聽 聽 聽 #else
聽 聽 聽 聽 聽pCertOpen 聽 聽= (PTYPECERTOPEN) GetProcAddress(HCrypt, "CertOpenSystemStoreA");
聽 聽 聽 聽 聽pCertGetName = (PTYPECERTGETNAME) GetProcAddress(HCrypt, "CertGetNameStringA");
聽 聽 聽 #endif
聽 聽 聽 pCertSelectDlg = (PTYPECERTSELECTDLG) GetProcAddress(HCrypt2, "CryptUIDlgSelectCertificateFromStore");
聽 聽 聽 pCertFreeCC 聽= (PTYPECERTFREECC) GetProcAddress(HCrypt, "CertFreeCertificateContext");
聽 聽 聽 pCertCloseStore 聽= (PTYPECERTCLOSESTORE) GetProcAddress(HCrypt, "CertCloseStore");
聽 聽}
聽 聽if (pCertOpen){
聽 聽 聽 // Llamada a CertOpenSystemStore:
聽 聽 聽 hStore = pCertOpen(NULL, TEXT("MY"));
聽 聽}
聽 聽if (hStore){
聽 聽 聽 // Di谩logo de selecci贸n de certificado:
聽 聽 聽 pCertContext = pCertSelectDlg(hStore, NULL, NULL, NULL, CRYPTUI_SELECT_LOCATION_COLUMN, 0, NULL);
聽 聽 聽 if (pCertContext){
聽 聽 聽 聽 聽cbSize = pCertGetName(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, NULL, 0);
聽 聽 聽 聽 聽if (cbSize>0) {
聽 聽 聽 聽 聽 聽 //Reservamos la memoria que necesitamos para el texto que recibiremos
聽 聽 聽 聽 聽 聽 sNombre = (LPTSTR)malloc(cbSize * sizeof(TCHAR));
聽 聽 聽 聽 聽 聽 pCertGetName(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, sNombre, cbSize);
聽 聽 聽 聽 聽 聽 // Llamada a CertFreeCertificateContext:
聽 聽 聽 聽 聽 聽 pCertFreeCC(pCertContext);
聽 聽 聽 聽 聽}
聽 聽 聽 }
聽 聽 聽 // Cerrar el almacen de certificados:
聽 聽 聽 // Llamada a CertCloseStore:
聽 聽 聽 pCertCloseStore(hStore, 0);
聽 聽 }
聽 聽 FreeLibrary(HCrypt);
聽 聽 FreeLibrary(HCrypt2);
聽 聽 hb_retc(sNombre);
}
#pragma ENDDUMP
Un saludo.