I tried creating a C# wrapper for the function however this is the first time I'm attempting to use unsafe code in C# and my C# skills are lacking anyway, so I'm running into some walls.
I can't read the result from the function, maybe anyone here knows what I'm doing wrong?
C# code:
using System;
using System.Runtime.InteropServices;
namespace EstimateFileRiskLevelWrapper
{
public class EstimateFileRiskLevelWrapper
{
[DllImport("winshfhc.dll", EntryPoint = "#101")]
public static extern int EstimateFileRiskLevel([MarshalAs(UnmanagedType.LPWStr)] String pszFilePath, [MarshalAs(UnmanagedType.LPWStr)] String pszExt, [MarshalAs(UnmanagedType.LPWStr)] String pszHandler, ref IntPtr riskLevel);
/*HRESULT EstimateFileRiskLevel(
LPCWSTR pszFilePath,
LPCWSTR pszExt,
LPCWSTR pszHandler,
FILE_RISK_LEVEL *pfrlEstimate
);*/
}
}
Trying to use the function with:
C# code:
EstimateFileRiskLevelWrapper.EstimateFileRiskLevelWrapper.EstimateFileRiskLevel(
fpath,
".php",
hpath,
ref risklevel);
IntPtr ptr = Marshal.ReadIntPtr(risklevel);
but I'm getting an AccessViolationException at the last line (reading the pointer).