This question was heavily edited to remove the (badly formatted) long preamble that explained the motivation. What the questioner is trying to do is call a DLL function with an argument whose type is dynamically defined in the call to DefineDLLFunction
. To get the full name of this type programmatically, you need to extract the name of the dynamically-defined namespace from the function returned by DefineDLLFunction
. This namespace is given by the context of the DRVUAOVoltageOut
symbol, which is "Wolfram`NETLink`DynamicDLLNamespace`DLLWrapper2`"
in the example (this got messed up a bit above because of bad formatting). The questioner wants to extract this context and use it to create the string name of the .NET type he wants to create to pass as an argument, which in this case will be "Wolfram.NETLink.DynamicDLLNamespace.DLLWrapper2+PT_AOVoltageOut"
.
Here is one way to do it. The original DefineDLLFunction
call looked like this:
f = DefineDLLFunction["
public class PT_AOVoltageOut
{
public ushort chan;
public float OutputValue;
}
[DllImport(\"Adsapi32.dll\",CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Auto, SetLastError = true)]
public static extern short DRV_AOVoltageOut( [In, Out] Int32 DriverHandle, PT_AOVoltageOut IntPtr);"
]
This returns the somewhat cryptic Function
shown in the original question. To create the type name:
ctxt = Context[Evaluate @ First @ Cases[f, If[_, sym_[_], _] :> sym]];
typeName = StringDrop[StringReplace[ctxt, "`" -> "."], -1] <> "+PT_AOVoltageOut";
Then, to create an object:
voltageOut = NETNew[typeName]
Part
can probabl do it... $\endgroup$