Re: moving data from one place to another in a text file

From: Richard (riplin_at_Azonic.co.nz)
Date: 02/26/05


Date: 26 Feb 2005 13:18:37 -0800


> The calling sequence to a .dll or .so is defined by the operating
system,
> independent of language.

You are now attempting to restrict what you meant by 'Calling
methodology' to that of specific types of calls. However, you once
again are a wonderful mine of misinformation:

"""Calling DLL's under Windows

Users of ACUCOBOL-GTŪ under Windows have the ability to call routines
packaged in Dynamic Link Libraries (DLL's) written in almost any
language. To achieve this there are a few things you need to know.

Firstly, there are two calling 'conventions', which specify how
parameters are passed to the DLL, under Windows, the C convention and
the Pascal convention. You can choose which convention to use by
setting the DLL-CONVENTION environment variable, remember you can use
SET ENVIRONMENT to set this. If you're not sure which convention is
used by a DLL just try one. If you've got it wrong you'll know pretty
quickly (can you spell GPF?).

Now we need to know how to call the DLL. If the DLL has only one
'entry-point' i.e. it only has one sub-routine packaged in it, and then
we can just call it by name:

   CALL "MYDLL.DLL" USING PARAM-1, PARAM-2.

The Windows runtime always looks for a file with the '.DLL' extension
if it doesn't find a COBOL program with the specified name, so we could
just say CALL "MYDLL". However we find it's easier to keep track of
what's going on if the extension is specified in the call.

Where the DLL has more than one entry-point we just call the DLL by
name to initialise it, then call the routine by name to run it. Let's
imagine that 'MYDLL.DLL' contains two routines 'routine1' and
'routine2'. We want to call 'routine2', so we code:

   CALL "MYDLL.DLL".
   CALL "routine2" USING PARAM-3.

The final thing we need to know is what format the DLL expects the
parameters to be in. The main thing here is whether it expects to get
the parameters as values or addresses. The default for ACUCOBOL-GTŪ is
to pass the address, also known as 'by reference'. If the DLL expects a
value, then you must specify BY VALUE on the parameter. Let's imagine
that we're calling 'routine1' which expects a number as its first
parameter and the address of a data item as its second; C programmers
will call this a 'pointer'. Since we've already called 'MYDLL.DLL' we
can just go ahead and call 'routine1':

   CALL "routine1" USING BY VALUE WS-NUMBER, WS-DATA-ITEM.

And that's it! It's really straightforward and opens up many
possibilities in the Windows world.""""

Or perhaps:

"""Q. Why do I get "Bad Calling Convention" when trying to call my VC++
dll from VB?

A. Visual Basic only supports calling functions in Dlls that are
declared with the __stdcall calling convention. This is different from
the default convention in VC++, __cdecl, which stands for "C' calling
convention. The two are not the same (but that's another topic) and are
not interchangeable. The solution? make sure you declare your dll's
functions as __stdcall.
"""



Relevant Pages

  • Re: The Lib debate
    ... >>Calling Functions in a DLL is a comletely different thing. ... For shared object libraries you have to call ... I have been told that zip comes with a Lib only. ...
    (alt.lang.asm)
  • Re: using the CWegPage.dll
    ... It is using the WINAPI (_stdcall) calling ... > The source code for the DLL is on that page and is in this link to the zip ... >> change the calling convention to that which VB can handle. ... >>> The goal is to put an internet explorer web browswer on my form. ...
    (microsoft.public.vc.language)
  • Re: using the CWegPage.dll
    ... It is using the WINAPI (_stdcall) calling ... > The source code for the DLL is on that page and is in this link to the zip ... >> change the calling convention to that which VB can handle. ... >>> The goal is to put an internet explorer web browswer on my form. ...
    (microsoft.public.vb.winapi)
  • Re: Mixed stdcall and cdecl code
    ... >> convention. ... I link to a 3rd party static library that apparently uses the ... >> errors from the linker until I changed my project settings from stdcall ... The 3rd party did not explicitly declare a calling convention in ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: How to debug load-time DLL exception?
    ... It is safe to call other functions in Kernel32.dll, ... Calling imported functions other than those located in Kernel32.dll may ... User, Shell, and COM functions can cause access violation errors, because ... here is the better stack trace:> ...
    (microsoft.public.win32.programmer.kernel)