Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / August 2006

Tip: Looking for answers? Try searching our database.

DllImport - C Function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alessandro - 23 Aug 2006 15:04 GMT
Hi all,

Please, anyone can help me? I need a invoke a C function from a unsafe
DLL. How to make a Dllimport call in C#?

There´s the function:
CLASS_DECLSPEC void WINAPI RCAL1901(const char *entrada,char *saida)
{
 int  codigo_veiculo;
 char descricao_veiculo[TAMMAX_DESCRICAO_VEICULO+1] = "";
 int  codigo_fabricante     = 0;
 int  ano_inicio_fabricacao = 0;
 int  mes_inicio_fabricacao = 0;
 int  ano_fim_fabricacao    = 0;
 int  mes_fim_fabricacao    = 0;

 codigo_veiculo = StoI(entrada,0,3);

 AcVeiculo(codigo_veiculo,
           descricao_veiculo,
           &codigo_fabricante,
           &ano_inicio_fabricacao,
           &mes_inicio_fabricacao,
           &ano_fim_fabricacao,
           &mes_fim_fabricacao);

 sprintf(saida,
         "%-*.*s%03d%04d%02d%04d%02d%02d%-*.*s",
         TAMMAX_DESCRICAO_VEICULO,TAMMAX_DESCRICAO_VEICULO,
         descricao_veiculo,
         codigo_fabricante,
         ano_inicio_fabricacao,
         mes_inicio_fabricacao,
         ano_fim_fabricacao,
         mes_fim_fabricacao,
         erro.codigo,
         TAMMAX_DESCRICAO_ERRO,TAMMAX_DESCRICAO_ERRO,
         erro.descricao);

 return;
}

Thanks,

Alessandro Pinto (Brazil)
Mattias Sjögren - 23 Aug 2006 20:19 GMT
>Please, anyone can help me? I need a invoke a C function from a unsafe
>DLL. How to make a Dllimport call in C#?

Teh declaration should look something like this

[DllImport("your.dll")]
static extern void RCAL1901(string entrada, StringBuilder saida);

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.