回复 9楼 吹水佬
stt就是那个结构体的指针
程序代码:
DECLARE long CredWriteA IN advapi32 as apiCredWrite string@,long DECLARE long CredReadA IN advapi32 as apiCredRead string@,long,long,long@ DECLARE long CredFree IN advapi32 as apiCredFree long DECLARE long _strdup IN msvcrt as apiStrdup string DECLARE long free IN msvcrt as apiFree long DECLARE long strlen IN msvcrt as apiStrlen long #define CRED_TYPE_GENERIC 1 #define CRED_TYPE_DOMAIN_PASSWORD 2 #define CRED_TYPE_DOMAIN_CERTIFICATE 3 #define CRED_TYPE_DOMAIN_VISIBLE_PASSWORD 4 #define CRED_TYPE_MAXIMUM 5 #define CRED_TYPE_MAXIMUM_EX (CRED_TYPE_MAXIMUM+1000) #define CRED_PERSIST_NONE 0 #define CRED_PERSIST_SESSION 1 #define CRED_PERSIST_LOCAL_MACHINE 2 #define CRED_PERSIST_ENTERPRISE 3 ? SaveCred("myTarget", "张三", "abc123") ? ReadCred("myTarget") FUNCTION SaveCred(cTargetName, cUserName, cPassword) pTargetName = apiStrdup(cTargetName) pUserName = apiStrdup(cUserName) pPassword = apiStrdup(cPassword) ** CREDENTIALA 结构 cred = 0h00000000; + BINTOC(CRED_TYPE_GENERIC, "4RS"); && Type + BINTOC(pTargetName, "4RS"); && TargetName + REPLICATE(0h00, 12); + BINTOC(apiStrlen(pPassword), "4RS"); && CredentialBlobSize + BINTOC(pPassword, "4RS"); && CredentialBlob + BINTOC(CRED_PERSIST_LOCAL_MACHINE, "4RS"); && Persist + REPLICATE(0h00, 12); + BINTOC(pUserName, "4RS") && UserName ret = apiCredWrite(@cred, 0) apiFree(pTargetName) apiFree(pUserName) apiFree(pPassword) RETURN ret != 0 ENDFUNC FUNCTION ReadCred(cTargetName) pCred = 0 IF apiCredRead(@cTargetName, CRED_TYPE_GENERIC, 0, @pCred) == 0 RETURN .F. ENDIF p = CTOBIN(SYS(2600,pCred+8,4),"4RS") ? "凭据名称:", SYS(2600, p, apiStrlen(p)) p = CTOBIN(SYS(2600,pCred+48,4),"4RS") ? "用户名称:", SYS(2600, p, apiStrlen(p)) p = CTOBIN(SYS(2600,pCred+28,4),"4RS") ? "用户密码:", SYS(2600, p, apiStrlen(p)) ? apiCredFree(pCred) RETURN .T. ENDFUNC