Help with finding entry point (

T

trint

I know that this function IS in this dll that comes with windows xp
that allows bidirectional printing (you can search "bidispl.dll" on
MSDN). However, I keep getting the same error all day, go to bed, get
up, get the same error over and over.
PLEASE Help! Here is the code and I'm just trying to get the FIRST
function to work and there are three more:
IBidiRequest Methods
Method - Description
SetSchema Sets the bidi schema string.
SetInputData Sets the data to send to the device.
GetResult Gets the result code.
GetOutputData Gets the output data coming back from the device.
GetEnumCount Gets the number of output items.

#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Data;
#endregion

[StructLayout(LayoutKind.Sequential)]
public struct DOCINFO
{
[MarshalAs(UnmanagedType.LPWStr)]
public string pszSchema;
[MarshalAs(UnmanagedType.LPWStr)]
public string hr;
[MarshalAs(UnmanagedType.LPWStr)]
public string pDataType;
}


namespace PInvoKe1
{
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

string str1;

DOCINFO di = new DOCINFO();

string shipping1 = (@"\\Web1\Shipping1");
str1 = shipping1;
Win32.SetSchema(str1);
// Win32.MsgBox(0, "", str1, 0);


// Win32.MsgBox(0, hPrinter, str1, 0);

}
}

public class Win32
{


[DllImport("User32.dll", EntryPoint = "MessageBox",
CharSet = CharSet.Auto)]
public static extern int MsgBox(int hWnd, String text, String
caption, uint type);

[DllImport("bidispl.dll")]
public static extern void SetSchema(string Param);

// hr = CoInitialize (NULL);


}

public class TestPInvoke
{

}
}

Thanks for your help!
Trint
 
B

Bob Grommes

Trint,

I have no experience with this particular DLL, but two resources that I've
found helpful for P/Invoke work are:

www.pinvoke.net

.... and the book, ".NET and COM -- The Complete Interoprability Guide" (SAMS
Publishing -- by Adam Nathan)

For anyone to give you specific help you're going to need to indicate
exactly what error you get, and where. But as an offhand observation, I
don't see where you're actually passing the DOCINFO struct to anything, or
populating it or using it in any way beyond declaring it, so I have some
doubt that you understand how to call these functions in the first place.

By the way, P/Invoke is for when you don't have a managed class that already
wraps Win32 functionality. So just use Windows.Forms.MessageBox.Show()
instead of P/Invoking directly to the Win32 equivalent.

--Bob
 
T

Trint Smith

Bob,
Thanks for your response...I'm looking at pinvoke.net right now. The
main thing is, I'm just trying to find a way to wrap bidispl.dll. If
you get some time, could you please take a look at this? It exists in
the system32 directory of xp (all versions, I think). I'm just
dumbfounded on how to get it to work at all...any help is very
appreciated.
Thanks,
Trint

Net programmer
(e-mail address removed)
 
W

Willy Denoyette [MVP]

trint said:
I know that this function IS in this dll that comes with windows xp
that allows bidirectional printing (you can search "bidispl.dll" on
MSDN). However, I keep getting the same error all day, go to bed, get
up, get the same error over and over.
PLEASE Help! Here is the code and I'm just trying to get the FIRST
function to work and there are three more:
IBidiRequest Methods
Method - Description
SetSchema Sets the bidi schema string.
SetInputData Sets the data to send to the device.
GetResult Gets the result code.
GetOutputData Gets the output data coming back from the device.
GetEnumCount Gets the number of output items.

#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Data;
#endregion

[StructLayout(LayoutKind.Sequential)]
public struct DOCINFO
{
[MarshalAs(UnmanagedType.LPWStr)]
public string pszSchema;
[MarshalAs(UnmanagedType.LPWStr)]
public string hr;
[MarshalAs(UnmanagedType.LPWStr)]
public string pDataType;
}


namespace PInvoKe1
{
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

string str1;

DOCINFO di = new DOCINFO();

string shipping1 = (@"\\Web1\Shipping1");
str1 = shipping1;
Win32.SetSchema(str1);
// Win32.MsgBox(0, "", str1, 0);


// Win32.MsgBox(0, hPrinter, str1, 0);

}
}

public class Win32
{


[DllImport("User32.dll", EntryPoint = "MessageBox",
CharSet = CharSet.Auto)]
public static extern int MsgBox(int hWnd, String text, String
caption, uint type);

[DllImport("bidispl.dll")]
public static extern void SetSchema(string Param);

// hr = CoInitialize (NULL);


}

public class TestPInvoke
{

}
}

Thanks for your help!
Trint

I told you before you CAN'T call these functions using PInvoke, they are no
exported C-style functions, these are COM (IUnknown) interface methods, so
you have to create an instance of the COM object before you can call them.
There is no typelib nor an IDL file available, so you can't build an interop
assembly either, so they are meant to be used from C/C++.
While you can handcraft the COM interop signatures yourself [1], your best
option is to write a Wrapper using MC++.

[1] Here is what I mean... Note that this is only an incomplete, untested
sample of one of the interfaces, just to give you an idea of what should be
done.
The interface description is taken from the bidispl.h header file.
[
ComImport,
Guid("D580DC0E-DE39-4649-BAA8-BF0B85A03A97"),
CoClass(typeof(BidiSplClass))
]
public interface BidiSpl: IBidiSpl
{
}

[
ComImport,
Guid("2A614240-A4C5-4c33-BD87-1BC709331639"),
ClassInterface(ClassInterfaceType.None)
]
public class BidiSplClass
{
}

[
ComImport,
Guid("D580DC0E-DE39-4649-BAA8-BF0B85A03A97"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)
]
public interface IBidiSpl
{
void BindDevice([In, MarshalAs(UnmanagedType.LPWStr)] string
pszDeviceName, int dwAccess);
void UnbindDevice();
void SendRecv([MarshalAs(UnmanagedType.LPWStr)] string pszAction, .....);
void MultiSendRecv([MarshalAs(UnmanagedType.LPWStr)] string pszAction,
......);
}
.....

......


Willy.
 
T

Trint Smith

Willy,
Does that mean that I have to rewrite my entire project in C++?
Thanks,
Trint

..Net programmer
(e-mail address removed)
 
T

Trint Smith

Willy,
I got it to work by creating an ALT OBJ as a proxy between the c# app
and the bidispl.dll. You were right. There was no other way.
Thanks,
Trinity

..Net programmer
(e-mail address removed)
 
Joined
Apr 3, 2008
Messages
1
Reaction score
0
Trinity,

I am actually looking to do the same thing that you were with attempting to wrap the bidispl stuff for .net

Any chance you'd be willing to share some of your work?

Please feel free to e-mail me hess.joel AT gmail.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top