home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!decwrl!mips!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsm!cbnewsk!hpd
- From: hpd@cbnewsk.cb.att.com (harold.p.debban)
- Newsgroups: comp.databases.informix
- Subject: Creating a MS-Windows DLL using esql/c for DOS
- Keywords: Windows, DLL, esql/c
- Message-ID: <1992Jul22.194038.23876@cbnewsk.cb.att.com>
- Date: 22 Jul 92 19:40:38 GMT
- Sender: Paul Debban
- Distribution: na
- Organization: AT&T
- Lines: 89
-
- Note: this is my first posting to netnews.
-
- I am attempting to use Informix esql/c for DOS, release 4.1 to write a
- Microsoft Windows Dynamic Link Library to link Windows applications such as
- WingZ, Microsoft Excel, or Visual Basic to my database using Informix-net.
-
- I have started with a simple function which executes the $database
- statement and returns sqlca.sqlcode. When I call the DLL from Visual Basic
- without running remsql, I get error -854, which is as expected. When I run
- remsql, load Windows, and call the DLL, I get a general protection fault in
- ldllsqlw.dll.
-
- I don't know if I am not allocating memory correctly, using the wrong compiler
- command line, or what. Technical support has not been able to help so far.
-
- Does anyone out there have any secrets to share? The Programmers Manual hints
- that what I want to do is possible, but offers no clues on how to make it work.
-
- Note: I have compiled and run the wdemo1.ec demo program included with esql/c
- without any problem, but I need the flexibilty of a DLL so that I can
- use a variety of Windows front ends.
-
- My environment is
- Compiler: Microsoft C 6.0
- Operating environment: MS-DOS 5.0, MS Windows 3.1 in enhanced mode, QEMM v6.0
- Network: AT&T StarGroup
-
-
- Compiler Command used
- esql -wd demo.ec libentry.obj demo.def -o demo.dll
-
- Source Code (demo.ec)
-
- #include <windows.h>
- $include sqlwproto.h;
- $include sqlca;
-
- /* Prototypes */
- long FAR PASCAL start_db();
-
-
- int FAR PASCAL LibMain(hModule, wDataSeg, cbHeapSize, lpszCmdLine)
- HANDLE hModule;
- WORD wDataSeg;
- WORD cbHeapSize;
- LPSTR lpszCmdLine;
- {
- return 1;
- }
-
- /*****************************
- FUNCTION: long start_db()
-
- PURPOSE: Open database.
-
- Returns: sqlerror code.
- ******************************/
-
- long FAR PASCAL start_db()
-
- {
- /* Open database */
-
- $ database stores2;
-
- return(sqlca.sqlcode);
- }
-
- VOID FAR PASCAL WEP (bSystemExit)
- int bSystemExit;
- {
- return;
- }
-
- ****************
- Definition file (demo.def)
- ****************
- LIBRARY demo
-
- EXETYPE WINDOWS
-
- CODE PRELOAD MOVABLE DISCARDABLE
- DATA PRELOAD SINGLE
-
- HEAPSIZE 10240
-
- EXPORTS
- WEP @1 RESIDENTNAME
- start_db @2
-