none
Help using native DLL function for my c# winforms RRS feed

  • Question

  • Hello everyone,

    This is a follow up question for my bill dispenser machine project.

    This is my Native DLL function Description:

    MFSSDM.DLL

    Function: MFSCommSDM_MultiDispense

    Parameters:
    LPSDMCBXITEM   lpCbxItem(in) // Number of notes will dispense of each cassette
    LPSDMMULTIDISPENSE lpMultiDispense(out) // Number of notes will dispense of each cassett

    Appropriate structure are defined as follows:

    typedef struct _sdm_cbx_item {
    BYTE count[MAX_CASSETTE]; // Number of notes will dispense of each cassette
    } SDMCBXITEM, *LPSDMCBXITEM;
    
    typedef struct _sdm_multi_dispense {
    BYTE error_cd;      // Error code on dispensing 
    BYTE pcount[MAX_CASSETTE];  // Number of notes were picked up
    BYTE rcount[MAX_CASSETTE];  // Number of notes were rejected
    BYTE dcount[MAX_CASSETTE];  // Number of notes were dispensed.
    }SDMMULTIDISPENSE, *LPSDMMULTIDISPENSE;

    Return Value: BOOL //Result of function execution

    Remarks: Start note Dispensing command of each cassette refer to number of dispensing notes requested (SDMCBXITEM Structure information). In case occurence of protocol performance error, dispensing error or number of dispensing notes do not match with dispensed note, return a 'FALSE'


    upon doing some research and asking questions. here is my c# code:

    const int MAX_CASSETTE = 8; public class SDMCBXITEM { [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_CASSETTE)] public byte[] count = new byte[MAX_CASSETTE]; } public class SDMMULTIDISPENSE { public byte error_cd; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_CASSETTE)] public byte[] pcount = new byte[MAX_CASSETTE]; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_CASSETTE)] public byte[] rcount = new byte[MAX_CASSETTE]; [MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_CASSETTE)] public byte[] dcount = new byte[MAX_CASSETTE]; } [return: MarshalAs(UnmanagedType.Bool)] [DllImport("MFSSDM.dll", CallingConvention = CallingConvention.StdCall)] public static extern bool MFSCommSDM_MULTIDISPENSE(ref SDMCBXITEM Cbxitem, ref SDMMULTIDISPENSE Multidispense);

    I've also created a simple form for testing that will allow me to input an int value on the textbox and a button to Dispense the bills.

    SimpleDispenseTest

    Tried this code for assigning the value of the textboxes:

    SDMCBXITEM cbx = new SDMCBXITEM();
    
    cbx.count[0] = Convert.ToByte(textBox1.Text);
    cbx.count[1] = Convert.ToByte(textBox2.Text);
    cbx.count[2] = Convert.ToByte(textBox3.Text);
    cbx.count[3] = Convert.ToByte(textBox4.Text);
    and I'm stuck again. and I'm not really sure if I'm understanding the DLL description correctly.

    Any help would be much appreciated. Thanks in advance!


    • Moved by Stanly Fan Thursday, January 24, 2019 7:09 AM
    Thursday, January 17, 2019 3:17 PM

Answers

  • Hi JinronCsharp,

    This forum is discussing and asking questions about the Windows Form and ClickOnce, and your question is not much related to this. So, in order to figure out how to use this API, the most effective way is to contact the API provider. 

    Thank you for your understanding.

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by JinronCsharp Friday, January 25, 2019 1:02 PM
    Thursday, January 24, 2019 7:08 AM

All replies

  • Hello,

    Where is the documentation for this API and where did you come across it?

    I noticed this thread, please when responding indicate more than you did over on Stackoverflow.

    Also, unsure about this but might this class be doing the same thing?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Thursday, January 17, 2019 11:41 PM
  • Hello,

    Where is the documentation for this API and where did you come across it?

    I noticed this thread, please when responding indicate more than you did over on Stackoverflow.

    Also, unsure about this but might this class be doing the same thing?



    Hello Karen,

    The API is from the machine manufacturer. Their SDK only includes the following files along with the description of the DLL functions posted above:

    • MFSSDM.dll
    • MFSSDM.h
    • MFSSDM.lib

    Thanks!

    Friday, January 18, 2019 5:14 AM
  • Hi JinronCsharp,

    This forum is discussing and asking questions about the Windows Form and ClickOnce, and your question is not much related to this. So, in order to figure out how to use this API, the most effective way is to contact the API provider. 

    Thank you for your understanding.

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by JinronCsharp Friday, January 25, 2019 1:02 PM
    Thursday, January 24, 2019 7:08 AM
  • Hi Kyle,

    I understand. Thank you.
    Friday, January 25, 2019 1:02 PM