Problem using WinVerifyTrust Function

VB_al 91 Reputation points
2021-02-04T18:04:08.69+00:00

Visual Basic .NET Framework

Hello, as @Drake Wu - MSFT said, I used WinVerifyTrust but
when I code
dim Result as long = WinVerifyTrust(........)
if result = 0 then
'verified successfully
else
'not verified
end if

it throws an exception: MarshalDirectiveException

I don't know ho to solve and i think i code GUID , pointer. . . . correctly..

Thanks

Windows development | Windows API - Win32
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Drake Wu - MSFT 996 Reputation points
    2021-02-05T02:24:24.053+00:00

    Hi, @VB_al MarshalDirectiveException seems to be caused by the calling convention of the function. The calling convention of WinVerifyTrust is the __stdcall:
    64270-1.png
    You can try to explicitly declare as CallingConvention = CallingConvention.StdCall. If this still does not solve the problem, please provide your sample which shows how you declare all the types and functions.


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.