home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / database / informix / 1588 < prev    next >
Encoding:
Text File  |  1992-07-22  |  2.5 KB  |  102 lines

  1. Path: sparky!uunet!olivea!decwrl!mips!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsm!cbnewsk!hpd
  2. From: hpd@cbnewsk.cb.att.com (harold.p.debban)
  3. Newsgroups: comp.databases.informix
  4. Subject: Creating a MS-Windows DLL using esql/c for DOS
  5. Keywords: Windows, DLL, esql/c
  6. Message-ID: <1992Jul22.194038.23876@cbnewsk.cb.att.com>
  7. Date: 22 Jul 92 19:40:38 GMT
  8. Sender: Paul Debban
  9. Distribution: na
  10. Organization: AT&T
  11. Lines: 89
  12.  
  13. Note: this is my first posting to netnews.
  14.  
  15. I am attempting to use Informix esql/c for DOS, release 4.1 to write a
  16. Microsoft Windows Dynamic Link Library to link Windows applications such as
  17. WingZ, Microsoft Excel, or Visual Basic to my database using Informix-net.
  18.  
  19. I have started with a simple function which executes the $database
  20. statement and returns sqlca.sqlcode. When I call the DLL from Visual Basic
  21. without running remsql, I get error -854, which is as expected. When I run
  22. remsql, load Windows, and call the DLL, I get a general protection fault in
  23. ldllsqlw.dll.
  24.  
  25. I don't know if I am not allocating memory correctly, using the wrong compiler
  26. command line, or what. Technical support has not been able to help so far.
  27.  
  28. Does anyone out there have any secrets to share? The Programmers Manual hints
  29. that what I want to do is possible, but offers no clues on how to make it work.
  30.  
  31. Note: I have compiled and run the wdemo1.ec demo program included with esql/c
  32. without any problem, but I need the flexibilty of a DLL so that I can
  33. use a variety of Windows front ends.
  34.  
  35. My environment is 
  36. Compiler:  Microsoft C 6.0
  37. Operating environment: MS-DOS 5.0, MS Windows 3.1 in enhanced mode, QEMM v6.0
  38. Network:   AT&T StarGroup
  39.  
  40.  
  41. Compiler Command used
  42. esql -wd demo.ec libentry.obj demo.def -o demo.dll
  43.  
  44. Source Code (demo.ec)
  45.  
  46. #include <windows.h>
  47. $include sqlwproto.h;
  48. $include sqlca;
  49.  
  50. /* Prototypes */
  51. long FAR PASCAL start_db();
  52.  
  53.  
  54. int FAR PASCAL LibMain(hModule, wDataSeg, cbHeapSize, lpszCmdLine)
  55. HANDLE    hModule;
  56. WORD    wDataSeg;
  57. WORD    cbHeapSize;
  58. LPSTR   lpszCmdLine;
  59. {
  60.     return 1;
  61. }
  62.  
  63. /*****************************
  64.    FUNCTION: long start_db()
  65.  
  66.    PURPOSE:  Open database.
  67.  
  68.    Returns:  sqlerror code.
  69. ******************************/
  70.  
  71. long FAR PASCAL start_db()
  72.  
  73. {
  74.     /* Open database   */
  75.  
  76.    $ database stores2;
  77.  
  78.    return(sqlca.sqlcode);
  79. }
  80.  
  81. VOID FAR PASCAL WEP (bSystemExit)
  82. int  bSystemExit;
  83. {
  84.     return;
  85. }
  86.  
  87. ****************
  88. Definition file (demo.def)
  89. ****************
  90. LIBRARY   demo
  91.  
  92. EXETYPE   WINDOWS
  93.  
  94. CODE      PRELOAD MOVABLE DISCARDABLE
  95. DATA      PRELOAD SINGLE
  96.  
  97. HEAPSIZE  10240
  98.  
  99. EXPORTS
  100.     WEP            @1 RESIDENTNAME
  101.     start_db        @2
  102.