Click here to Skip to main content
16,010,268 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionI try to create an array of objects from a class but I get Object reference not set to an instance of an object. Pin
nico200721-May-09 6:07
nico200721-May-09 6:07 
AnswerRe: I try to create an array of objects from a class but I get Object reference not set to an instance of an object. Pin
Dave Kreskowiak21-May-09 6:48
mveDave Kreskowiak21-May-09 6:48 
GeneralRe: I try to create an array of objects from a class but I get Object reference not set to an instance of an object. Pin
nico200721-May-09 7:02
nico200721-May-09 7:02 
GeneralRe: I try to create an array of objects from a class but I get Object reference not set to an instance of an object. Pin
Dave Kreskowiak21-May-09 7:56
mveDave Kreskowiak21-May-09 7:56 
AnswerRe: I try to create an array of objects from a class but I get Object reference not set to an instance of an object. Pin
nlarson1121-May-09 8:13
nlarson1121-May-09 8:13 
AnswerRe: I try to create an array of objects from a class but I get Object reference not set to an instance of an object. Pin
DidiKunz23-May-09 11:33
DidiKunz23-May-09 11:33 
QuestionHow to use cryptSignMessage function from crypt32.dll Pin
YSR 141021-May-09 5:24
YSR 141021-May-09 5:24 
AnswerRe: How to use cryptSignMessage function from crypt32.dll Pin
omnibaer10-Jan-13 7:39
omnibaer10-Jan-13 7:39 
Try the following code:

VB
Public Function SignMsg(CertContext As Long) As Boolean
    'make the CryptoAPI sign an arbitrary message using the user's signing certificate; should invoke a PIN prompt if PIN is not cached
    Dim SigParams As CRYPT_SIGN_MESSAGE_PARA
    Dim MessageArray(0 To 0) As String
    Dim MessageSizeArray(0 To 0) As Long
    Dim cbSignedMessageBlob As Long
    Dim pbSignedMessageBlob As String
    Dim GLE As Long
    Dim rtn As Boolean

    Const szOID_RSA_ENCRYPT = "1.2.840.113549.3"
    Const szOID_OIWSEC_sha1 = "1.3.14.3.2.26"

    On Error GoTo erh

    ' Initialize the signature structure.
    SigParams.dwMsgEncodingType = PKCS_7_ASN_ENCODING
    SigParams.pSigningCert = CertContext
    SigParams.HashAlgorithm.pszObjId = szOID_OIWSEC_sha1
    SigParams.HashAlgorithm.Parameters = 0
    SigParams.cMsgCert = 1
    SigParams.rgpMsgCert = CertContext
    SigParams.cAuthAttr = 0
    SigParams.dwInnerContentType = 0
    SigParams.cMsgCrl = 0
    SigParams.cUnauthAttr = 0
    SigParams.dwFlags = 0
    SigParams.pvHashAuxInfo = 0
    SigParams.rgAuthAttr = 0
    SigParams.cbSize = Len(SigParams)

    MessageArray(0) = "A message" + vbNullChar
    MessageSizeArray(0) = Len(MessageArray(0))

    ' First, get the size of the signed BLOB.
    rtn = CryptSignMessage(VarPtr(SigParams), _
                           False, _
                           1, _
                           MessageArray, _
                           MessageSizeArray, _
                           0, _
                           VarPtr(cbSignedMessageBlob) _
                          )
    GLE = GetLastError
    If rtn = False Then
        err.Raise 4021, , "Failed to retrieve signed blob size: " & GLE
    End If

    pbSignedMessageBlob = String(cbSignedMessageBlob, vbNullChar) 

    ' Get the signed message BLOB.
    rtn = CryptSignMessage(VarPtr(SigParams), _
                           False, _
                           1, _
                           MessageArray, _
                           MessageSizeArray, _
                           VarPtr(pbSignedMessageBlob), _
                           VarPtr(cbSignedMessageBlob) _
                          )
    GLE = GetLastError
    If rtn = False Then
        err.Raise 4022, , "Failed to sign message blob: " & GLE
    End If
    SignMsg = True
    Exit Function
erh:
    SignMsg = False
End Function


Requires a good certificate context passed in, plus:

Private Declare Function CryptSignMessage Lib "Crypt32" ( _
    ByVal pSignPara As Long, _
    ByVal fDetachedSignature As Boolean, _
    ByVal cToBeSigned As Long, _
    ByRef rgpbToBeSigned() As String, _
    ByRef rgcbToBeSigned() As Long, _
    ByVal pbSignedBlob As Long, _
    ByVal pcbSignedBlob As Long _
    ) As Boolean

GeneralRe: How to use cryptSignMessage function from crypt32.dll Pin
Member 1412881424-Jan-19 6:09
Member 1412881424-Jan-19 6:09 
Questionhow to use .bas in VB.Net Pin
cod3newbie21-May-09 3:26
cod3newbie21-May-09 3:26 
AnswerRe: how to use .bas in VB.Net Pin
Dave Kreskowiak21-May-09 3:50
mveDave Kreskowiak21-May-09 3:50 
AnswerRe: how to use .bas in VB.Net Pin
EliottA21-May-09 11:18
EliottA21-May-09 11:18 
GeneralRe: how to use .bas in VB.Net Pin
cod3newbie22-May-09 6:25
cod3newbie22-May-09 6:25 
GeneralRe: how to use .bas in VB.Net Pin
EliottA22-May-09 6:40
EliottA22-May-09 6:40 
GeneralRe: how to use .bas in VB.Net Pin
DidiKunz23-May-09 11:37
DidiKunz23-May-09 11:37 
GeneralRe: how to use .bas in VB.Net Pin
cod3newbie24-May-09 7:12
cod3newbie24-May-09 7:12 
GeneralRe: how to use .bas in VB.Net Pin
DidiKunz24-May-09 7:45
DidiKunz24-May-09 7:45 
QuestionRe: how to use .bas in VB.Net Pin
cod3newbie2-Jun-09 15:02
cod3newbie2-Jun-09 15:02 
AnswerRe: how to use .bas in VB.Net Pin
DidiKunz2-Jun-09 20:42
DidiKunz2-Jun-09 20:42 
QuestionRe: how to use .bas in VB.Net Pin
cod3newbie3-Jun-09 16:53
cod3newbie3-Jun-09 16:53 
AnswerRe: how to use .bas in VB.Net Pin
DidiKunz3-Jun-09 19:42
DidiKunz3-Jun-09 19:42 
GeneralRe: how to use .bas in VB.Net Pin
cod3newbie3-Jun-09 23:25
cod3newbie3-Jun-09 23:25 
QuestionNull Pin
No-e21-May-09 3:15
No-e21-May-09 3:15 
AnswerRe: Null Pin
Dave Kreskowiak21-May-09 3:49
mveDave Kreskowiak21-May-09 3:49 
GeneralRe: Null Pin
No-e21-May-09 4:37
No-e21-May-09 4:37 

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.