1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Rep Power

    Trying to make WebCam Application


    I create the following code:
    #define		WM_CAP_START			0x0400 #define		WM_CAP_DRIVER_CONNECT		(WM_CAP_START + 10) #define 	WM_CAP_DRIVER_DISCONNECT	(WM_CAP_START + 11) #define		WM_CAP_EDIT_COPY		(WM_CAP_START + 30) #define 	WM_CAP_GRAB_FRAME		(WM_CAP_START + 60) #define 	WM_CAP_SET_SCALE		(WM_CAP_START + 53) #define 	WM_CAP_SET_PREVIEWRATE		(WM_CAP_START + 52) #define 	WM_CAP_SET_PREVIEW		(WM_CAP_START + 50) #define 	WM_CAP_DLG_VIDEOSOURCE		(WM_CAP_START + 42) #define 	WM_CAP_STOP			(WM_CAP_START+ 68) #define 	WM_CAP_FILE_SET_CAPTURE_FILE	(WM_CAP_START+ 20) #define 	WM_CAP_FILE_SAVEDIB		(WM_CAP_START+  25) #define 	WM_CAP_SEQUENCE 		(WM_CAP_START + 62) #define		WM_SYSICON			(WM_USER + 1)  #include	<windows.h> #include	<windowsx.h> #include	<vfw.h> #include	<Exdisp.h>			//IID_IWebBrowser2 #include	<OleAuto.h>			//varianinit #include	<winuser.h> #include	<commctrl.h> #include	<psapi.h>			//GetModuleFileNameEx #include	<string.h> #include	<wininet.h> #include	<C:\\xampp\\mysql\\include\\mysql.h> #include	<odbcinst.h> #include	<sql.h> #include	<sqlext.h> #include	"Strings.h" #include	"Sql.h" #include	<shlobj.h>			// For IShellLink #include	<richedit.h> #include	<objidl.h>			// For IPersistFile  #pragma comment(lib,"vfw32.lib") #pragma comment(lib,"gdi32.lib")  HWND hwndMain = NULL; WNDCLASSEX wc = {0}; static HWND hCam; MSG msg;  #define VFWAPI WINAPI //extern "C" {HWND WINAPI capCreateCaptureWindowA (LPCSTR,DWORD,LONG,LONG,LONG,LONG,HWND,LONG);} //HWND WINAPI capCreateCaptureWindowA (LPCSTR,DWORD,LONG,LONG,LONG,LONG,HWND,LONG); HWND VFWAPI capCreateCaptureWindowA (LPCSTR lpszWindowName,DWORD dwStyle,int x,int y,int nWidth,int nHeight,HWND hWnd,int nID); typedef HWND (VFWAPI *LDCAPWND)(LPCWSTR,DWORD,int,int,int,int,HWND,int); typedef HWND (VFWAPI *LDCAP)(HWND,int); typedef BOOL (WINAPI *WTS_RSF)(HWND,DWORD); typedef BOOL (WINAPI *WTS_USF)(HWND); typedef HWND (WINAPI *cCCW)(LPCWSTR,DWORD,int,int,int,int,HWND,int);    LRESULT CALLBACK MainMessageHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { 	HMODULE hMod; 	LDCAPWND _capCreateCaptureWindowW; 	WTS_RSF p_WTSRSF; 	WTS_USF p_WTSUSF; 	switch (uMsg) 	{ 		case WM_CREATE: 		{ 			HWND hWndc; 			HMODULE hMod; 			cCCW lpFunc; 			hMod = LoadLibrary("AVICAP32.DLL"); 			if(!hMod) 			{ 				MessageBox(NULL,"Error - module","Error",MB_OK | MB_ICONERROR); 			} 			lpFunc = (cCCW)GetProcAddress(hMod,"capCreateCaptureWindowW"); 			if(!lpFunc) 			{ 				MessageBox(NULL,"Error - function","Error",MB_OK | MB_ICONERROR); 			} 			hWndc = lpFunc((LPCWSTR) "Windows App",WS_CHILD | WS_VISIBLE,10, 10, 320, 240,hwnd,(int)32); 			//SendMessage(hWndc,WM_CAP_DRIVER_CONNECT,0,0); 			FreeLibrary(hMod); 			break; 		} 		case WM_DESTROY: 		{ 			//p_WTSUSF(hwnd);	//WTSUnRegisterSessionNotification(hwnd); 			PostQuitMessage(0); 			break; 		} 	}  	return DefWindowProc(hwnd, uMsg, wParam, lParam); }      INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE reserved, LPSTR szCommand, INT nShow) { 	HICON hIcon; 	char strText[255] = {0}; 	long fwidth,fheight; 	HDC hdc;  	wc.cbSize        = sizeof(wc); 	wc.style         = CS_DBLCLKS; 	wc.cbClsExtra    = 0; 	wc.cbWndExtra    = 0; 	wc.hInstance     = GetModuleHandle(NULL); 	wc.hCursor       = LoadCursor(NULL, IDC_ARROW); 	wc.lpfnWndProc   = MainMessageHandler; 	wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION); 	wc.hIconSm       = NULL; 	wc.hbrBackground = 6; 	wc.lpszMenuName  = NULL; 	wc.lpszClassName = TEXT("SimpleEditContainer"); 	if(RegisterClassEx(&wc)) 	{ 		hdc = CreateDC(TEXT("display"), NULL, NULL, NULL); 		fwidth = GetDeviceCaps(hdc, HORZRES); 		fheight = GetDeviceCaps(hdc, VERTRES); 		hwndMain = CreateWindowEx( 					WS_EX_ACCEPTFILES, 					TEXT("SimpleEditContainer"), TEXT("Sistem Informasi Kasir"),  					WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX, 					0, 0, fwidth, fheight, 					NULL, NULL, GetModuleHandle(NULL), NULL); 		ShowWindow(hwndMain, 1); 	}  	while ( GetMessage(&msg, NULL, 0, 0) ) 	{ 		TranslateMessage(&msg); 		DispatchMessage(&msg); 	} 	return (int) msg.wParam; }

    Then, I compile with this:
    gcc source.c -o source libraryProfCAT/winmm.lib libraryProfCAT/comdlg32.lib libraryProfCAT/wininet.lib libraryProfCAT/gdi32.lib libraryProfCAT/comctl32.lib libraryProfCAT/vfw32.lib libraryProfCAT/netapi32.lib libraryProfCAT/mpr.lib libraryProfCAT/iphlpapi.lib libraryProfCAT/ole32.lib libraryProfCAT/winspool.lib libraryProfCAT/setupapi.lib libraryProfCAT/shlwapi.lib libraryProfCAT/wtsapi32.lib libraryProfCAT/oleaut32.lib -lmysql -lodbc32 -lodbccp32 -lws2_32 -lwinmm -lpsapi -luuid -lole32

    And I run source.exe, but the application terminate automatically. Are you have same problem with me?
    Help please :confused:

  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Rep Power
    I suggest you look at your post again, and figure out whether "all the code on one line" is in any way acceptable.

    Nobody is going to give you any time at all until you show reasonably presentable code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo