Announcement

Collapse
No announcement yet.

C Convertion

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • C Convertion

    To be able to use a Data Translation acquisition board , I have had to create a DLL
    from Visual C++, to which I can use from my PB application.
    I need help for declaring a function that figures in the following way in the include
    file of C:

    Code:
    #ifdef STRICT
    typedef BOOL (CALLBACK *DABRDPROC) (PTSTR pszBrdName, PTSTR pszEntry, LPARAM lParam);
    #else
    typedef FARPROC DABRDPROC;
    #endif
    
    ECODE WINAPI olDaEnumBoards (DABRDPROC pfnDaBrdProc, LPARAM lParam);

    Maybe something like that??

    Code:
    DECLARE FUNCTION olDaEnumBoards LIB "olDa32.dll" ALIAS "olDaEnumBoards" (BYVAL lpszName AS ANY, BYVAL LParam AS LONG) AS LONG
    DABRDPROC is a callback procedure.
    The callback function must take the following form:

    Code:
    BOOL __export CALLBACK DaBrdProc (LPSTR lpszBrdName, LPSTR
    lpszDriverEntry, LPARAM lParam)
    Name lpszName
    Type LPSTR
    Description The board name, passed as an ASCII string.
    Range N/A

    Name lpszDriverEntry
    Type LPSTR
    Description The driver name and parameters. (For example, "dt3831.drv 0x260
    10 6a 7b" indicates that a DT3831 driver is installed at I/O port 260
    (hex) with IRQ 10, DMA channel 6 for the ADC, and DMA channel 7
    for the DAC.)
    Range N/A

    Name lParam
    Type LPARAM
    Description The value passed to olDaEnumBoards.
    Range N/A

    Well, any help would be appreciate, thank in advance...

    ------------------
    Gustavo Asplanatti
    [email protected]

    [This message has been edited by Gustavo Asplanatti (edited March 22, 2006).]
    Gustavo Asplanatti
    gustavoa at computecsrl.com.ar

  • #2
    Upss... Sorry for the Topic name... I have written it very hurried,
    I don't know if it is possible to fix it...

    Evidently my English is not very good...

    ------------------
    Gustavo Asplanatti
    [email protected]
    Gustavo Asplanatti
    gustavoa at computecsrl.com.ar

    Comment


    • #3
      totally guessing here

      looks like (BYVAL lpszName AS ANY, BYVAL LParam AS LONG) AS LONG
      should be (BYVAL pfnDaBrdProc AS LONG, BYVAL LParam AS LONG) AS LONG

      If I understand right, it’s up to you to write this function:
      BOOL __export CALLBACK DaBrdProc (LPSTR lpszBrdName, LPSTR
      lpszDriverEntry, LPARAM lParam)

      You then pass a CODEPTR(DaBrdProc) with the right parameters to olDaEnumBoards


      ------------------

      Comment


      • #4
        >byval lpszname as any,

        "byval as any" does not make any sense

        pb translation, usage
        Code:
        declare function oldaenumboards lib "olda32.dll" alias "oldaenumboards" _
            (byval cbaddr as dword, byval lparam as long) as long
        
        function callbackfunction(szbrdname as asciiz, szentry as asciiz, byval lparam as long) as long
        
        end function
        ...
          call oldaenumbrds (codeptr (callbackfunction), lparam) to ecode
        although this was about (shudder) translating from one language to another, this might be helpful to understand enums to callback procs in general:

        pb/win: write your own enum functions september 23, 2002


        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment

        Working...
        X