About *.lib *.h &*.dll

kaveh rahimi 61 Reputation points
2021-06-14T12:11:30.197+00:00

Hi ,I have three files CH341DLL.H ,CH341DLL.LIB & CH341DLL.DLL ,I want to add #include directive to it in my source code for CH341DLL.H and for CH341DLL.LIB add it to linker with -|CH341DLL argument and for CH341DLL.DLL I've been told to place it in system32 but my OS is windows 10 64 bit. I don't know how to do these works.
Please help me.
Thanks

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,142 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. RLWA32 45,576 Reputation points
    2021-06-14T12:25:44.943+00:00

    I've been told to place it in system32 but my OS is windows 10 64 bit. I don't know how to do these works.

    It is bad practice to place user DLLs in the system folders. The best location for most user DLLs is in the folder that contains the application that uses them.

    2 people found this answer helpful.
    0 comments No comments

  2. Castorix31 85,546 Reputation points
    2021-06-14T12:35:00.393+00:00

    Put the .h + .lib with your other sources
    +
    the .dll in the executable directory.

    1 person found this answer helpful.
    0 comments No comments

  3. RLWA32 45,576 Reputation points
    2021-06-15T15:04:56.183+00:00

    You are executing code from a third-party DLL. If the functions you are calling are not returning the expected results then either your expectations are incorrect or errors exist in the way you are using the functions.

    In any case, you need to refer to the documentation of the functions exported by CH341DLL.DLL to resolve the specific issues that you are experiencing when using this third-party software.

    1 person found this answer helpful.
    0 comments No comments

  4. RLWA32 45,576 Reputation points
    2021-06-14T13:33:37.027+00:00

    If you place the .lib file with your other source you need to instruct the linker how to find it.
    One way is the include a statement like this in the source code -

        #pragma comment(lib, "CH341DLL.lib")  
    

    Another way is to set the "Additional Dependencies" property in the project's Linker->Input.

    Go to the property sheet and click the down arrow (highlighted in red)
    105424-linker-input.png
    Then, if you placed your .lib file in the same folder as your sources (which should be the project folder containing the .vcxproj file) set the following
    105441-linker-lib.png

    Now the property page should look like this
    105388-linkerdone.png

    Accept the settings and close the property page.


  5. kaveh rahimi 61 Reputation points
    2021-06-15T10:47:59.147+00:00

    I'd used declare statement in my code:
    Private Declare Function CH341OpenDevice Lib "CH341DLL.DLL" (ByVal iIndex As Integer) As Integer
    Private Declare Function CH341WriteI2C Lib "CH341DLL.DLL" (ByVal iindex As Integer, ByVal idevice As Integer, ByVal iaddr As Integer, ByVal ibyte As Integer) As Boolean
    Private Declare Function CH341ReadI2C Lib "CH341DLL.DLL" (ByVal iindex As Integer, ByVal idevice As Integer, ByVal iaddr As Integer, ByVal obyte As Integer) As Integer
    Private Declare Function CH341CloseDevice Lib "CH341DLL.DLL" (ByVal iIndex As Integer) As Integer
    Private Declare Function CH341ResetDevice Lib "CH341DLL.DLL" (ByVal iIndex As Integer) As Integer
    Sub main()
    MsgBox("ok")
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim opening As Integer
        Dim closing As Integer
        Dim writing As Integer
        Dim reading As Integer
        Dim reseting As Integer
        reseting = CH341ResetDevice(0)
        opening = CH341OpenDevice(0)
        writing = CH341WriteI2C(0, 86, 22, 90)
        reading = CH341ReadI2C(0, 48, 91, 91)
        closing = CH341CloseDevice(0)
        MsgBox(reseting)
        MsgBox(writing)
        MsgBox(closing)
    End Sub
    

    But when I run the code it returns value of CH341WriteI2C() wrong(for example zero).


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.