Here is my DLL:
.686						; Pentium Pro Instructions
.model flat, stdcall
option casemap:none ; Case sensitive compilation


; DLL Entry procedure
CamCaptureMain proc hInstDLL:HINSTANCE, Reason:DWORD, Reserved1:DWORD

mov eax, hInstDLL
mov hInstance, eax

.elseif eax == DLL_PROCESS_DETACH

xor eax, eax
inc eax

CamCaptureMain endp

CamConnect proc hWnd:HWND


CamConnect endp

CamDisconnect proc


CamDisconnect endp

end CamCaptureMain

includelib kernel32.lib
includelib user32.lib
includelib vfw32.lib


;public CamConnect, CamDisconnect

IDD_DLG1 equ 1000
IDC_BTN1 equ 1001


CapWndWidth dd 320
CapWndHeight dd 240


CapWndName db 'CapWnd',0


hInstance dd ?
hCapDlg dd ?
hCapWnd dd ?

And I have also a resource file, which contains only a simple dialog with a button.
When I Build the project, everything builds fine. The DLL, LIB, EXP is created. however in the .DEF file nothing appears, and if I open the DLL in a hex viewer the DLL will NOT contain the names of CamConnect and CamDisconnect, so i cannot import the functions. I just simply don't get it. Have you any ideea what am I doing wrong?

Note that I made the project with the RadASM project wizard, thus the compiling options should be ok.
Posted on 2005-05-13 06:30:28 by bszente
I think the DEF file is the problem. I did not wrote any exports in the DEF file. Isn't the DEF file automatically generated?
What is exactly the purpose of the DEF file?
Posted on 2005-05-13 06:54:28 by bszente
yeah its the DEF file
if u want DLL for camera capture, i have something written with DirectShow, not old vidcap APIs
Posted on 2005-05-13 07:59:53 by comrade
This should do:


LIBRARY CamCapture

The DEF file is not automatically generated (well, some C/C++ editors do, but that's another story). It simply puts together some options for the linker. I understand (please correct me if I'm wrong) that most, if not all, options set by the DEF file can be replaced with linker commandline switches.
Posted on 2005-05-13 13:32:04 by QvasiModo
Thanks guys for your answers. I managed to compile the DLL with those EDF directives.
I have 3 functions: CamConnect, CamDisconnect and GetFrame.
However I encountered another bizarre problem:
I made a small program in C++ that uses this DLL. It's working fine. One of my friend is doing the other part (image processing part) of the project also in C++ (using MinGW). When he calls from my Assmbly language made DLL the CamConnect and CamDisconnect functions it works ok.
The problem is with GetFrame, I found that after he calls the GetFrame procedure, his program crashs. BUT NOT in my DLL, after the returning from the DLL.
If I let the GetFrame proc to be a simple RET, his program crashed the same way.
Strange is that the same DLL worked well with my test C++ program. I tough that his program is not working well, but he had not any problem with his demo DLL (written in C++).

I rewrote the DLL in C++, using Visual C++ Toolkit 2003, and now the DLL is working with with project too. I made exactly the same things, but in C.
Conclusion: the DLL made by MASM32 was not 100% compatible with C++, and I think due to some calling convention conflicts (I used STDCALL). This is my 1st such situation. Is there any directives or keywords or some special callling conventions that I do not know? Do you have any ideea what was happening? I think I will try to debug it with OllyDbg, but I don't have time now.

Is C++ handling differently in some cases the DLL calls? (BTW I made it using LoadLibrary and GetProcAddress).

I would welcome any help in this question, becuase it's realy frustrating how my MASM32 DLL tricked me.

Comrade: yes I'm doing WebCam capture. In fact I just want to write a GetFrame procedure for my webcam. I don't have any experience using directShow, so I would welcome some advice regarding it. I managed to do it with AVICAP, using WM_CAP_GRAB_FRAME, but I'm sure that with DirectShow is much more performant. Is it possible to do the frame grabbing in background, I mean not to open a Capture window like in AVICAP case?
I'm working on a little project to drive a toy-car based on this webcam.

Thanks guys for your help.

PS: I don't get email notifications any more from the forum, if somebody replied to one of the threads where I'm subscribed. Am I a moron, or something happened with the forum? I think this is only from a few days. And in the profile options in the notification list there are many threads, and I have checked the "Send notification" option.
Posted on 2005-05-13 15:30:02 by bszente
C/C++ uses C convention if I'm not wrong, the header should specify the stdcall convention. Other than that, I wouldn't know...
Posted on 2005-05-13 15:54:00 by QvasiModo
Yes, QvasiModo, you're right. I used stdcall (that's the default btw). When I will have some free time, I will debug it to see what is realy happening. It's realy interesting.
Posted on 2005-05-13 17:32:23 by bszente

I have a DLL made it in C++ using ATL. DirectShow is much more suitable for capturing using web cameras. With AVICAP, you will find that you cannot programmatically choose which camera to capture from (if you have mutliple cameras). The setting will only be available through a user configuration dialog box. However, with DirectShow it is possible to capture using multiple cameras.
Posted on 2005-05-14 14:28:23 by comrade