Calling the DEMOM471.DLL from C#

11 views
Skip to first unread message

Com1 Software

unread,
Apr 25, 2010, 4:37:35 PM4/25/10
to Com1 Software DLL Development
Tony,

Here are a few examples of how to call an unmanaged dll in c#



This is an example of a console application that displays information
popup about the DLL.


using System.Runtime.InteropServices;
using System;

class PInvoke1App
{
[DllImport("c:\\demof472\\demom471.dll")]
static extern int C1COMMAND0(string strCaptiona);

public static void Main()
{
C1COMMAND0("ABOUTDLL");
}
}




This is an example of a console application that returns the version
of the DLL.

using System.Runtime.InteropServices;
using System;


class PInvoke1App
{
[DllImport("c:\\demof472\\demom471.dll")]
static extern string C1COMMAND0(string strCaptiona);

public static void Main()
{
string ret=C1COMMAND0("GETDLLVERSION");
Console.WriteLine("Return Value: " + ret);
}
}



Here are a couple of links that I found useful:

http://www.codeproject.com/KB/cs/unmanage.aspx
http://www.adp-gmbh.ch/csharp/call_dll.html

Thanks
Dave



--
Subscription settings: http://groups.google.com/group/com1-software-dll-development/subscribe?hl=en

Com1 Software

unread,
Apr 29, 2010, 2:13:20 PM4/29/10
to Com1 Software DLL Development
Here is a console application that calls C1COMMAND5
--------------------


using System.Runtime.InteropServices;
using System;


class PInvoke1App
{
[DllImport("H:\\c1\\demof472\\demom471.dll")]
static extern string C1COMMAND5(string strCaptiona, string
strCaptionb, string strCaptionc, string strCaptiond, string
strCaptionde, string strCaptiondf);

public static void Main()
{
string ret = C1COMMAND5("CMDTEST5", "PARM1", "PARM2", "PARM3",
"PARM4", "PARM5");
Console.WriteLine("Return Value: " + ret);
}
}



--------------------
When this application is run from a DOS prompt this is what you should
see:

c:\test>consoleapplication
Return Value: CMDTEST5 PASS1 PASS2 PASS3 PASS4 PASS5

c:\test>



Tony Grewal

unread,
Apr 29, 2010, 9:06:24 PM4/29/10
to com1-software-...@googlegroups.com
Dave; there appears to be a conflict with the number of arguments that
are sent to C1COMMAND5. You show 6 parameters here yet there are 5 when
using your X12 DLL downloaded example. Would you please clarify? Thanks.

I am using:
string refx = C1COMMAND5("PARSE", "XML", "<SourceFile>",
"<OutputFileName>", "OW");

Am I doing something incorrectly?
Disclaimer - April 29, 2010
This email and any files transmitted with it are confidential and intended solely for com1-software-...@googlegroups.com. If you are not the named addressee you should not disseminate, distribute, copy or alter this email. Any views or opinions presented in this email are solely those of the author and might not represent those of Key Health Group. Warning: Although Key Health Group has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments.
This disclaimer was added by Policy Patrol: http://www.policypatrol.com/

infor...@com1software.com

unread,
Apr 30, 2010, 6:57:27 AM4/30/10
to com1-software-...@googlegroups.com
Tony,

The 5 vs 6 is confusing and maybe we need to address it better.


refx = C1COMMAND5("PARSE", "XML", "<SourceFile>",
"<OutputFileName>", "OW","");


You may need to add the extra parameter at the end to make it work or drop back to
C1COMMAND4. We were going to use the last parameter to pass additional dll data.

Thanks
Dave

Tony Grewal

unread,
Apr 30, 2010, 5:25:43 PM4/30/10
to com1-software-...@googlegroups.com
Hi Dave; well I just ran the application via a shell command in .NET. I
did not get any errors but neither did I get an XML file output. I used
the 6 parameters DLL call. Any ideas what I may have done wrong? Thanks.

Com1 Software

unread,
May 4, 2010, 12:19:05 PM5/4/10
to Com1 Software DLL Development
Tony,

In the demo of the dll parser we only include parser functions in the
exe and not in the dll

With the demo dll you should be able to verify that you can properly
pass parameters to the dll
and get a return value in the programming language of your choice.

Make sure that you were able to get or display the return value
CMDTEST5 PASS1 PASS2 PASS3 PASS4 PASS5
using your application.

Thanks
Dave


Tony Grewal

unread,
May 6, 2010, 6:46:03 PM5/6/10
to com1-software-...@googlegroups.com
Thanks Dave for your help regarding adjusting the number of line items
one can display for a claim by editing the 837P.XML file. My next
question regards the ODBC connection to a SQL Server database. How does
one use the X12 DLL parser to write data to a SQL Server database? Can
this be done in code? How does it know what fields to write to? What if
you wanted to edit the parameters being sent to the DB? Would you be
able to point me in the right direction? Thanks again.

-----Original Message-----
From: com1-software-...@googlegroups.com
[mailto:com1-software-...@googlegroups.com] On Behalf Of
Com1 Software
Sent: Tuesday, May 04, 2010 9:19 AM
To: Com1 Software DLL Development
Subject: Re: Calling the DEMOM471.DLL from C#

Disclaimer - May 6, 2010

Com1 Software

unread,
May 12, 2010, 12:59:10 PM5/12/10
to Com1 Software DLL Development
Tony,

We have some basic training on the odbc that we have set up here that
might help.
http://com1software.com/training/C1D0F252.htm

The dll and the exe parser work the same when it comes to the odbc.

This thread has some additional detail on the subject
http://groups.google.com/group/com1-software-dll-development/browse_thread/thread/9c98b93b5c7c2a2e

Thanks
Dave
Reply all
Reply to author
Forward
0 new messages