Error when adding System32 dependencies such as shell32.dll

dear community

I am trying to get the video duration of a rather big list of videos into one spread.

Inputing all the filenames into Filestream (EX9.Texture VLC) doesnt work for me, vvvv crashes.
So I followed this http://www.levibotelho.com/development/get-the-length-of-a-video-in-c/, trying to write a dynamic plugin. Both approaches use dependencies from the System32 Folder. e. g. when I trying to use shell32.dll, i get the following error:

Metadata file ´c:\Windows\System32\shell32.dll´ could not be opened -- ´An attempt was made to load a program with an incorrect format.´

of course I added the dll in the project… no success. google suggest its related to the systemarchitecture x86 or 64bit…
I´m using 45beta32.1 x86
any ideas?

thank you all

hi,
is it a mamanged or a unmanaged dll? If it is a unmanaged you can’t add it as dependency via Project-Expolerer. You have to call the funcitons from the dll via System.Runtime.InteropServices.

also see
https://discourse.vvvv.org/t/11901

hi phlegma

thanks for your quick reply.
aparently its unmanaged. I was able to import the dll the way you suggested. I see how I can call the function but not how I can assign a variable of a type defined in the required dll.

Is there a way to use these types, so I could write:

var shell = new Shell();

any ideas?

not quite sure if i understand your question and i’m not very experienced in c# either, however,

if your looking to retrieve whatever the function returns it works for me like that (given the return type is e.g. an int)

int return = yourDLLFunction ();

if the function in the dll you are calling has parameters, and you intend/have to set these you need to specify these parameters first at the dll import

System.Runtime.InteropServices.DllImport("yourDLL.dll")]
private static extern int yourDLLFunction(int param1);

and then call the function inside evaluate like:

int myParam = 0;//change here to your needs
int return = yourDLLFunction(myParam);

i can’t give a lot of insight in that code, but i can testify it wotks ;)

it’s a little more complicated if the argument of your imported function is a c++ pointer like

System.Runtime.InteropServices.DllImport("yourDLL.dll")]
private static extern int yourDLLFunction(char* Name);

then you will have to use delegates/marshalling, allocate buffers and so on, trying to figure that out atm ;) any help with that very appreciated too…

hi
i have seen this.

But this can only be done via IDE and not via dynamic plugin because its a reference to com object.