none
c dll RRS feed

  • Question

  • Hello i am a new programmer and i am calling a dll file from winform at c#

    but my dll supposed to show a console window and get a number that wil be transfer back to c#

    winform,and it dose not working .

    if i wand a dll to return a value it dose work .

    so how can i do that my dll will work with commands as printf or scanf e.t.c...

    Thank you .

    • Moved by lucy-liu Tuesday, July 5, 2011 3:50 AM it is related to clr (From:Visual C++ General)
    Saturday, July 2, 2011 12:47 PM

Answers

  • Hi iliyatz,

    I am not familiar with C language. But in a Winform application, we could P/Invoke AllocConsole API function to use console.

            [DllImport("kernel32.dll")]
            public static extern Boolean AllocConsole();
            [DllImport("kernel32.dll")]
            public static extern Boolean FreeConsole();

    We could call AllocConsole API when we need to run a console, after using it, we could call FreeConsole to close and free it.

    The API is unmanaged, I think you could call it via C language too.

    I hope this can help you.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Paul Zhou Monday, July 11, 2011 10:08 AM
    Thursday, July 7, 2011 7:45 AM

All replies

  • Are you calling native C/C++ DLL from managed application C#? Or trying to call managed DLL from Managed application. If you trying to call  managed DLL, you can check with the following link (Vegab already added in his comments)

    http://social.msdn.microsoft.com/Forums/en-US/category/visualcsharp

     

    If you want invoke C DLL from managed application ex C#, you should check with the following link

    http://msdn.microsoft.com/en-us/library/55d3thsc%28VS.80%29.aspx


    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/
    Saturday, July 2, 2011 2:26 PM
  • Hi Ayrosa,

    I am moving this thread from “Visual C++ General" forum to the “Common Language Runtime” forum.

    since the issue is related to CLR. There are more experts in the “Common Language Runtime" forum.

    Thank you for your understanding!

     

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 5, 2011 3:49 AM
  • Hi iliyatz,

    I am not familiar with C language. But in a Winform application, we could P/Invoke AllocConsole API function to use console.

            [DllImport("kernel32.dll")]
            public static extern Boolean AllocConsole();
            [DllImport("kernel32.dll")]
            public static extern Boolean FreeConsole();

    We could call AllocConsole API when we need to run a console, after using it, we could call FreeConsole to close and free it.

    The API is unmanaged, I think you could call it via C language too.

    I hope this can help you.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Paul Zhou Monday, July 11, 2011 10:08 AM
    Thursday, July 7, 2011 7:45 AM