⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dll.txt

📁 遗传算法工具箱 希望高手指点 GATOOLS
💻 TXT
📖 第 1 页 / 共 2 页
字号:
  #define GSDLL_DEVICE 3  /* device = str has been opened if count=1 */
                          /*                    or closed if count=0 */
  #define GSDLL_SYNC 4    /* sync_output for device str */ 
  #define GSDLL_PAGE 5    /* output_page for device str */
  #define GSDLL_SIZE 6    /* resize for device str */
                          /* LOWORD(count) is new xsize */
                          /* HIWORD(count) is new ysize */
  #define GSDLL_POLL 7    /* Called from gp_check_interrupt */
			  /* Can be used by caller to poll the message queue */
			  /* Normally returns 0 */
			  /* To abort gsdll_execute_cont(), return a */
			  /* non zero error code until gsdll_execute_cont() */
			  /* returns */

==========================
Example DLL usage for OS/2
==========================
The following example shows a minimal usage of the Ghostscript DLL.
The example callback function above is needed.

#define INCL_DOS
#include <os2.h>
#include <stdio.h>
#include "gsdll.h"

PFN_gsdll_init pgsdll_init;
PFN_gsdll_execute_begin pgsdll_execute_begin;
PFN_gsdll_execute_cont pgsdll_execute_cont;
PFN_gsdll_execute_end pgsdll_execute_end;
PFN_gsdll_exit pgsdll_exit;

HMODULE hmodule_gsdll;
char buf[256];

int
main(int argc, char *argv[])
{
int code;
APIRET rc;
	if (!DosLoadModule(buf, sizeof(buf), "GSDLL2", &hmodule_gsdll)) {
	    fprintf(stderr, "Loaded GSDLL2\n");
	    DosQueryProcAddr(hmodule_gsdll, 0, "gsdll_init", (PFN *)(&pgsdll_init));
	    DosQueryProcAddr(hmodule_gsdll, 0, "gsdll_execute_begin", (PFN *)(&pgsdll_execute_begin));
	    DosQueryProcAddr(hmodule_gsdll, 0, "gsdll_execute_cont", (PFN *)(&pgsdll_execute_cont));
	    DosQueryProcAddr(hmodule_gsdll, 0, "gsdll_execute_end", (PFN *)(&pgsdll_execute_end));
	    DosQueryProcAddr(hmodule_gsdll, 0, "gsdll_exit", (PFN *)(&pgsdll_exit));
	}
	else {
	    fprintf(stderr, "Can't load GSDLL2\n");
	}

	code = (*pgsdll_init)(gsdll_callback, NULL, argc, argv);
	fprintf(stdout,"gsdll_init returns %d\n", code);
	code = (*pgsdll_execute_begin)();
	if (code==0) {
	    while (fgets(buf, sizeof(buf), stdin)) {
	        code = (*pgsdll_execute_cont)(buf, strlen(buf));
	        fprintf(stdout,"gsdll_execute returns %d\n", code);
		if (code < 0)
		   break;
	    }
	    if (!code)
	        code = (*pgsdll_execute_end)();
	    code = (*pgsdll_exit)();
	    fprintf(stdout,"gsdll_exit returns %d\n", code);
	}
	rc = DosFreeModule(hmodule_gsdll);
	fprintf(stdout,"DosFreeModule returns %d\n", rc);
	return 0;
}

===============================
Ghostscript DLL device for OS/2
===============================
The os2dll device is provided in the Ghostscript DLL for use
by the caller.  No drawing facilities are provided by the DLL
because the DLL may be loaded by a text only (non PM) application.

The caller will be notified via the gsdll_callback when a new
os2dll device is opened or closed (GSDLL_DEVICE), when the window 
should be redrawn (GSDLL_SYNC or GSDLL_PAGE) or when the bitmap 
size changes (GSDLL_SIZE).

Note that more than one os2dll device may be opened.

One DLL function is available for accessing the os2dll device:

----------------
gsdll_get_bitmap
----------------
The following function returns a pointer to a bitmap in BMP format.
The os2dll device draws into this bitmap.

unsigned long gsdll_get_bitmap(unsigned char *device, unsigned char **pbitmap);
 /* return in pbitmap the address of the bitmap */
 /* device is a pointer to Ghostscript os2dll device from GSDLL_DEVICE message */

The caller can then display the bitmap however it likes, but should 
lock the bitmap with gsdll_lock_device() before painting from it, 
and unlock it afterwards.  The bitmap address will not change until
the os2dll device is closed, however the bitmap size and palette
may change at any time the bitmap is not locked.

=====================================
Ghostscript DLL device for MS-Windows
=====================================
The mswindll device is provided in the Ghostscript DLL for use
by the caller.  

The caller will be notified via the gsdll_callback when a new
mswindll device is opened or closed (GSDLL_DEVICE), when the window 
should be redrawn (GSDLL_SYNC or GSDLL_PAGE) or when the bitmap 
size changes (GSDLL_SIZE).

Note that more than one mswindll device may be opened.

Four extra DLL functions are available for accessing the mswindll device:

--------------
gsdll_copy_dib
--------------
This function is commonly used when copying the mswindll bitmap
to the clipboard.

/* make a copy of the device bitmap and return shared memory handle to it */
/* device is a pointer to Ghostscript device from GSDLL_DEVICE message */
HGLOBAL GSDLLAPI gsdll_copy_dib(unsigned char *device);

------------------
gsdll_copy_palette
------------------
This function can be used when copying the mswindll palette
to the clipboard.

/* make a copy of the device palette and return a handle to it */
/* device is a pointer to Ghostscript device from GSDLL_DEVICE message */
HPALETTE GSDLLAPI gsdll_copy_palette(unsigned char *device);

----------
gsdll_draw
----------
This function is used for displaying output from the mswindll device.  
The caller should create a window and call gsdll_draw in response to 
the WM_PAINT message.  The device context hdc must be for a device 
because SetDIBitsToDevice() is used.

/* copy the rectangle src from the device bitmap */
/* to the rectangle dest on the device given by hdc */
/* hdc must be a device context for a device (NOT a bitmap) */
/* device is a pointer to Ghostscript device from GSDLL_DEVICE message */
void GSDLLAPI gsdll_draw(unsigned char *device, HDC hdc, 
                                  LPRECT dest, LPRECT src);

--------------------
gsdll_get_bitmap_row
--------------------
The following function returns a BMP header, a palette and a pointer
to a row in the bitmap.

int GSDLLAPI gsdll_get_bitmap_row(unsigned char *device, LPBITMAPINFOHEADER pbmih,
    LPRGBQUAD prgbquad, LPBYTE *ppbyte, unsigned int row)
/* Copy bitmap
 * If pbmih nonzero, copy the BITMAPINFOHEADER.
 * If prgbquad nonzero, copy the palette.
 *   number of entries copied is given by pbmih->biClrUsed
 * If ppbyte nonzero, return pointer to row.
 *   pointer is only valid while device is locked
 * GS can change the palette while the device is locked.
 * Do not call this function while GS is busy.
 *
 * This function exists to allow the bitmap to be copied to a file
 * or structured storage, without the overhead of having two copies
 * of the bitmap in memory at the same time.
 */

================
MS-Windows 16bit
================
This platform has the most problems of the three.
Support for it may be dropped in future.

The Win16 DLL (GSDLL16.DLL) is a large memory model DLL with far 
static data.  Due to the limitations of 16 bit MS-Windows, the DLL 
can used by only one program at a time.
However, GSDLL16 is marked as having SINGLE SHARED data segments which
allows multiple applications to load GSDLL16.  (The DLL wouldn't load
at all if MULTIPLE NONSHARED was used).  Applications loading GSDLL16
should check the return value of gsdll_init().  If it is non-zero
then GSDLL16 is already in use by another application and should NOT
be used.  GSDLL16 should be unloaded immediately using FreeLibrary(),
or the caller program should terminate.

The segmented architecture of the 80286 causes the usual amount of
grief when using GSDLL16.
Because the callback is called from the DLL which is using a different
data segment, the callback must be declared as _far _export.
  int _far _export gsdll_callback(int message, char *str, unsigned long count);
Instead of giving gsdll_init the address of gsdll_callback, it should
instead be given the address of a thunk created by MakeProcInstance.
This thunk changes the data segment back to that used by the caller:
  FARPROC lpfnCallback;
  lpfnCallback = (FARPROC)MakeProcInstance((FARPROC)gsdll_callback, hInstance);
  code = (*pgsdll_init)((GSDLL_CALLBACK)lpfnCallback, NULL, argc, argv);
  if (!code) {
      fprintf(stderr, "GSDLL16 is already in use\n");
      return -1;
  }

==================
Changes 1996-09-05
==================
Ghostscript locks the device just before closing it, to prevent 
closing the device while the caller is drawing from it.

Added gsdll_get_bitmap_row() to MS-Windows.

==================
Changes 1996-07-02
==================
gsdll_init() error code changed.

==================
Changes 1996-05-30
==================
gsdll_init() error code changed.

==================
Changes 1996-05-16
==================
Added HWND as a parameter to gsdll_init().
THIS IS A NON BACKWARD COMPATIBLE CHANGE.

Documented that gsdll_execute_end() must not be called if 
gsdll_execute_cont() returns with error.


==================
Changes 1996-03-16
==================
New call back message GSDLL_POLL.

Removed OS/2 gsdll_lock_bitmap().  Replaced by gsdll_lock_device().

Add gsdll_lock_device to OS/2 and MS-Windows.
 For non multi-threaded environments (Win16, Win32s) this will
 return a lock count but return immediately.
 For multi-threaded environments this will maintain a lock
 using a mutex (which may block).

Changed gsdll_init() to take argc and argv.  Now supports the
  full range of Ghostscript command line options.

*** OS/2 has't been tested yet.

==================
Changes 1995-07-26
==================
gsdll_revision needs to be checked before using other APIs,
 to protect against finding a later version of the GS DLL
 with changed APIs.
 
gsdll_execute removed.
gsdll_execute_begin/cont/end added.
 Keywords can now be split across calls to gsdll_execute_cont.
 DLL input can now be done without using the stdin callback

Now use GSDLLAPI instead of WINAPI
 Under Windows, the calling convention is CALLBACK, not pascal.
 For Win32 this is _stdcall, for Win16 this is _far _pascal.


Original version 1994-07-03

====================
/* end of dll.txt */
====================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -