im trying to make my own include file but im having some difficulty with the conversion from .h to inc. the header file im converting is winnetwk.h and some of the contents im not sure how to convert. for example i converted this:

DWORD APIENTRY
WNetAddConnectionA(
     IN LPCSTR   lpRemoteName,
     IN LPCSTR   lpPassword,
     IN LPCSTR   lpLocalName
    );

to this:

WNetAddConnectionA DWORD
     lpRemoteName  LPCSTR
     lpPassword    LPCSTR
     lpLocalName   LPCSTR
WNetAddConnectionA ENDS

=====================================================

and not sure how to convert this:

typedef UINT (FAR PASCAL *PFNGETPROFILEPATHA) (
    LPCSTR    pszUsername,
    LPSTR     pszBuffer,
    UINT      cbBuffer
    );

hope someone can help.. maybe hutch or iczelion? smurf
Posted on 2001-04-21 16:32:00 by smurf
smurf, The first one is reasonably straight forward, the 3 structure members are addresses so they can be set as DWORD. The DWORD after STRUCT sets the structure as DWORD aligned, the "?" after each member means that the structure members are uninitialised data. The following equate is so you can use the documented name without the "A" suffix.

WNetAddConnectionA STRUCT DWORD
    lpRemoteName  DWORD ?
    lpPassword    DWORD ?
    lpLocalName   DWORD ?
WNetAddConnectionA ENDS

WNetAddConnection equ 
The second one is a problem in that it appears to be a 16 bit windows structure,

typedef UINT (FAR PASCAL *PFNGETPROFILEPATHA) (
               LPCSTR    pszUsername,
               LPSTR     pszBuffer,
               UINT      cbBuffer
               );
FAR usually means a segmented FAR call which usually denotes a segmented memory model, not flat memory model that is used in win 32. The 3 members are easy enough, pszUsername DWORD ? pszBuffer DWORD ? cbBuffer DWORD ? What it may be is a piece of original 16 bit code that was ported to 32 bit without having the call range modernised, if so it can be written with the structure name like normal and you can ignore the FAR PASCAL. Regards, hutch@pbq.com.au
Posted on 2001-04-21 19:02:00 by hutch--
While we are on the topic, check out "h2inc.exe", it might be in you masm32\bin folder, or you can download it from hutches or iczelion site. I know it converts equates typedefs etc, and im farily sure about structures.
Posted on 2001-04-21 20:10:00 by George
They are not structures at all. They are declarations for windows based function calls. They should look like the following PROCDESC WNetAddConnectionA lpRemoteName:LPCSTR,lpPassword:LPCSTR, lpLocalName:LPCSTR and PROCTYPE PFNGETPROFILEPATHA pszUsername:LPCSTR, pszBuffer:LPSTR, cbBuffer:UINT the second is what amounts to a pointer based function call. The delphi equivalent is a procedure type declaration. Repeat - these are not structure declarations.
Posted on 2001-04-21 20:43:00 by DelphianOracle7
hutch thank you for your reply and hopefully to bring closesure to all my questions maybe you can answer these last few i have on the subject? you made the conversion like this:
WNetAddConnectionA STRUCT DWORD
    lpRemoteName  DWORD ?
    lpPassword    DWORD ?
    lpLocalName   DWORD ?
WNetAddConnectionA ENDS
but couldnt it be converted to this instead to allow consistency between the .h file and the .inc?:
WNetAddConnectionA STRUCT DWORD
    lpRemoteName  LPCSTR ?
    lpPassword    LPCSTR ?
    lpLocalName   LPCSTR ?
WNetAddConnectionA ENDS
another thing is that your equ line looks like this:
WNetAddConnection equ 
but is it not the same thing as writing it like this?:
WNetAddConnection typedef WNetAddConnectionA
ok here's another question and should be my last. Sometimes at the end of the Structs and sometimes at the beggining of a paramter there will be a star in front of a word such as *lplpSystem what is the meaning of this star anyways? here what it looked like at the end of a struct:
typedef struct  _NETRESOURCEA {
    DWORD    dwScope;
    DWORD    dwType;
    DWORD    dwDisplayType;
    DWORD    dwUsage;
    LPSTR    lpLocalName;
    LPSTR    lpRemoteName;
    LPSTR    lpComment ;
    LPSTR    lpProvider;
}NETRESOURCEA, *LPNETRESOURCEA;
<--- hmmmm thank you for your time thanks george but i get errors using h2inc for some reason. for example i get errors such as this one:
error H1206: syntax error : identifier 'DWORD'
so i deleted all the DWORD's from the .h file just to see what would happen and it just moved on to another error such as this:
error H1206: syntax error : identifier 'LPSTR'
Posted on 2001-04-21 20:50:00 by smurf
smurf, I think DelphianOracle7 is correct that they are function calls, not structures, I did not take a lot of notice and just convered what you had in the post. Now a couple of things, in the current WINDOWS.INC, data types like LPCSTR are typdefed to DWORD. The native assembler data type for 32 bit is DWORD and this includes addresses. I would not hold out much hope with h2inc.exe as it does not handle C++ header file well at all. I have seen some older C headers converted with it but in many instances, you get the errors you mentioned. My C is very rusty now but I think the "*" denoted a pointer to a variable. WNetAddConnection equ I used this line to make an equate as it is a name, not a data type, you can use typdef to create new data types with no problems if you need them. Regards, hutch@pbq.com.au
Posted on 2001-04-22 10:08:00 by hutch--
disease_2000 what purpose does the pointer serve anyways? could i just leave it out of the conversion? LPNETRESOURCEA pointer NETRESOURCEA <--- why would i need this pointer? smurf
Posted on 2001-04-24 17:01:00 by smurf
C/C++ is occasionally overly pedantic, rather frantic actually, in it's insistance that everything be typedefined. So if you have a FOO, and wish a pointer to a FOO, you need declare a type "LPFOO pointer FOO", such that a LPFOO may ONLY point at a FOO and nothing else (least it produce compile errors). Since Windows defines some 90 base types that are ALL DWORDS, some savy good looking fellow (OK, it wasn't me, it was hutch) defined the include files with loose type checking, and just look for the size of the data. This makes MASM32 much much easier to use. ML.EXE does support strict type checking IF you go ahead and define a multitude of types. But trust me, don't do that; that way leads to madness.
Posted on 2001-04-24 23:18:00 by Ernie
Posted on 2001-04-25 00:27:00 by NaN