The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Trying to make WebCam Application
Discuss Trying to make WebCam Application in the C Programming forum on Dev Shed. Trying to make WebCam Application C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 7th, 2012, 12:42 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 1
Time spent in forums: 14 m 49 sec
Reputation Power: 0
|
|
|
Trying to make WebCam Application
Hi,
I create the following code:
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
Thanks!
|

November 7th, 2012, 01:31 AM
|
 |
Contributed User
|
|
|
|
|
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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|