Click here to Skip to main content
15,891,689 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: get Download Time of a File Pin
Dave Kreskowiak24-Mar-11 2:00
mveDave Kreskowiak24-Mar-11 2:00 
AnswerRe: get Download Time of a File Pin
Dalek Dave24-Mar-11 4:08
professionalDalek Dave24-Mar-11 4:08 
AnswerRe: get Download Time of a File Pin
Аslam Iqbal24-Mar-11 12:10
professionalАslam Iqbal24-Mar-11 12:10 
AnswerRe: get Download Time of a File [Solved] Pin
εїзεїзεїз25-Mar-11 1:26
εїзεїзεїз25-Mar-11 1:26 
QuestionContextMenuStrip Pin
Dominick Marciano21-Mar-11 8:41
professionalDominick Marciano21-Mar-11 8:41 
AnswerRe: ContextMenuStrip Pin
Luc Pattyn21-Mar-11 9:01
sitebuilderLuc Pattyn21-Mar-11 9:01 
GeneralRe: ContextMenuStrip Pin
Dominick Marciano21-Mar-11 13:44
professionalDominick Marciano21-Mar-11 13:44 
QuestionCryptCreateHash returns zero, invalid parameter Pin
garfield18521-Mar-11 5:26
garfield18521-Mar-11 5:26 
Hi.

I'm trying to encrypt text using advapi32.dll function CryptEncrypt, RC4.

Before encrypting, y call CryptAcquireContext and CryptCreateHash, but this last one returns me zero. Err.LastDllError says it is an 87, so invalid parameter, but can't figure out where is the error.

    Private Const ALG_CLASS_HASH As Long = 32768             ' (4 < 13)
    Private Const ALG_TYPE_ANY As Long = 0
    Private Const ALG_SID_MD5 As Long = 3
    Private Const CALG_MD5 As Long = ALG_CLASS_HASH Or ALG_TYPE_ANY Or ALG_SID_MD5

    ....

    Private Declare Function CryptAcquireContext Lib "advapi32.dll" Alias "CryptAcquireContextA" _
    (ByRef phProv As Long, _
    ByVal pszContainer As String, _
    ByVal pszProvider As String, _
    ByVal dwProvType As Long, _
    ByVal dwFlags As Long) As Long

Private Declare Function CryptCreateHash Lib "advapi32.dll" _
    (ByVal hProv As Long, _
    ByVal algID As Long, _
    ByVal hKey As Long, _
    ByVal dwFlags As Long, _
    ByRef phHash As Long) As Long
    ...

    'CryptAcquireContext works fine
    lResult = CryptAcquireContext(m_lProvider, sKeyRoot, CRYPTO_PROVIDER, PROV_RSA_FULL, 0)
    If lResult = 0 Then
        lResult = CryptAcquireContext(m_lProvider, sKeyRoot, CRYPTO_PROVIDER, PROV_RSA_FULL, CRYPT_NEWKEYSET)
        If lResult = 0 Then
            MsgBox(ERROR_AQUIRING_CONTEXT)
        End If
    End If


    'Now this is where I get zero
    ' Create a handle to a hash object  using the MD5 algorithm
    lResult = CryptCreateHash(m_lProvider, CALG_MD5, 0, 0, lHash)
    If lResult = 0 Then
        Dim a As Long = Err.LastDllError
        MsgBox(ERROR_CREATING_HASH)
        Return ""
    End If


Any idea what I am missing?
AnswerRe: CryptCreateHash returns zero, invalid parameter Pin
Luc Pattyn21-Mar-11 5:39
sitebuilderLuc Pattyn21-Mar-11 5:39 
GeneralRe: CryptCreateHash returns zero, invalid parameter Pin
garfield18521-Mar-11 5:48
garfield18521-Mar-11 5:48 
GeneralRe: CryptCreateHash returns zero, invalid parameter Pin
Dave Kreskowiak21-Mar-11 6:25
mveDave Kreskowiak21-Mar-11 6:25 
AnswerRe: CryptCreateHash returns zero, invalid parameter Pin
Luc Pattyn21-Mar-11 7:02
sitebuilderLuc Pattyn21-Mar-11 7:02 
Question[SOLVED] How to Insert / update value in Microsoft Access Database via UDP? [modified] Pin
Yance Lawang21-Mar-11 2:58
Yance Lawang21-Mar-11 2:58 
AnswerRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Dave Kreskowiak21-Mar-11 4:08
mveDave Kreskowiak21-Mar-11 4:08 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? [modified] Pin
Yance Lawang21-Mar-11 13:45
Yance Lawang21-Mar-11 13:45 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Dave Kreskowiak21-Mar-11 14:48
mveDave Kreskowiak21-Mar-11 14:48 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Yance Lawang21-Mar-11 17:03
Yance Lawang21-Mar-11 17:03 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Dave Kreskowiak21-Mar-11 18:06
mveDave Kreskowiak21-Mar-11 18:06 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Yance Lawang21-Mar-11 20:10
Yance Lawang21-Mar-11 20:10 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? [modified] Pin
Yance Lawang23-Mar-11 16:21
Yance Lawang23-Mar-11 16:21 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Dave Kreskowiak23-Mar-11 17:55
mveDave Kreskowiak23-Mar-11 17:55 
GeneralRe: How to Insert / update value in Microsoft Access Database via UDP? Pin
Yance Lawang23-Mar-11 20:06
Yance Lawang23-Mar-11 20:06 
QuestionMarshal structure Pin
Sonhospa20-Mar-11 1:44
Sonhospa20-Mar-11 1:44 
AnswerRe: Marshal structure Pin
Dave Kreskowiak20-Mar-11 5:01
mveDave Kreskowiak20-Mar-11 5:01 
GeneralRe: Marshal structure Pin
Sonhospa20-Mar-11 21:49
Sonhospa20-Mar-11 21:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.