.DLL MACRO api,args:VARARG
	LOCAL dargs,dtype

	IFNDEF _PROTO_&api
		dargs TEXTEQU <>
		_PROTO_&api = 0
		IFNB <args>
			FOR arg, <args>
				dargs CATSTR dargs,<,:DWORD>
				_PROTO_&api = _PROTO_&api + 4
			ENDM
			dargs SUBSTR dargs,2 ;; Strip the first comma
		ENDIF
		dtype CATSTR <_PTYPE_>,%_PROTO_&api
		IFNDEF %dtype
			dtype TYPEDEF PROTO dargs
		ENDIF
		dargs CATSTR <EXTERNDEF _imp__>,<api>,<@>,%_PROTO_&api,<:PTR >,dtype
		dargs
	ENDIF
	dargs CATSTR <_imp__>,<api>,<@>,%_PROTO_&api
	IFB <args>
		invoke dargs
	ELSE
		invoke &dargs,args
	ENDIF
ENDM


;; UNICODE version for above ;)
.uDLL MACRO api,args:VARARG
	IFDEF _UNICODE_
		.DLL api&W,args
	ELSE
		.DLL api&A,args
	ENDIF
ENDM


;; C Calling convention
.cDLL MACRO api,args:VARARG
	.DLL api,args
	add esp,_PROTO_&api
ENDM


;; UNICODE C Calling convention
.ucDLL MACRO api,args:VARARG
	IFDEF _UNICODE_
		.cDLL api&W,args
	ELSE
		.cDLL api&A,args
	ENDIF
ENDM
