So after about a day and a half with this I’ve made zero progress.
I need to write a DLL in C that is used a plugin for an existing application.
The DLL has to be compiled by the Visual Studio 2008 compiler with the following options
cl -DNT40 -DPOMDLL -DCRTAPI1=_cdecl -DCRTAPI2=cdecl -D_WIN32 -DWIN32 -DWIN32_LEA
N_AND_MEAN -DWNT -DBYPASS_FLEX -D_INTEL=1 -DIPLIB=none -I. -I”C:\plm\2T-RAC\TcEx
press53\include” -I”C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include”
-c -nologo -EHsc -W1 -Ox -Oy- -MD C:\mydir\myDll.c
It’s then linked to applications library’s.
What it actually needs to do and what’s causing me the issues is that within one of the methods it needs to pull data from a sql server 2008 r2.
From what I’ve seen today you wouldn’t be able to do this directly in C as SQL Server past 2005 is designed to communicate with CLR languages( C#, C++, VB.Net).
It was suggested that I handle all the database communication with a VB.Net dll and then call said function from within the C dll.
Most of what I’ve found on the topic of calling managed dll’s from unmanaged code has talked about pinvoke or com wrappers and mainly from the perspective of c++.
I have zero experience with COM or any mentioned techniques so if anyone could help out it would be much appreciated.
The way I resolved this was simply having the C dll call cmd and execute a compile VB.NET executable and pipe it’s output.
Although this isn’t wasn’t a totally ideal solution it worked in this situation when all I required back was a single string.