|
How about NetUserEnum?
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
|
|
|
|
|
Thanks!your answer is very valuable.
|
|
|
|
|
If you have several cameras installed, only one device is available for VFW32 (cap* API) always - WDM Capture Driver for VFW. When you try to open several cameras at once, you have to manually choose which camera by a dialogue-box provided by this WDM device driver. Is there anyway to programmatically choose which camera?
comrade
http://comrade64.cjb.net/
|
|
|
|
|
I remember having heaps of problems with the VFW camera API, so much so that we eventually gave up and used DirectShow. DirectShow incidentally makes makes choosing cameras quite easy, some of the samples are quite easy to extend from an arbitrary number of cameras.
DirectShow abstracts the use of VFW or WDM's under the covers, so it doesn't matter which drivers you have, and the additional functionality can be very helpful.
BTW: Just a quick warning, if you intend to stream from multiple cameras at once, it's likely that you will have problems. I'm not sure where the problems start - possibly in the shear bandwidth required to use multiple cameras, but you may end up with frames, or parts of frames, from different cameras 'jumping' streams. Similarly last time I was pushing DirectShow with multiple cameras we had problems with showing multiple video windows at the same time.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Thanks for your reply. I am aware of DirectShow API, and it is probably a better choice - but we are using Visual Basic for this application and right now just VFW seems to be implementable.
comrade
http://comrade64.cjb.net/
|
|
|
|
|
For a school project, I am re-writing the data access code from a Visual Basic application into C++. I used the C++ class wizard to set up the recordset classes and have tested those classes to ensure they connect to the MySQL database and retrieve the information. That all works! Now, its time to hook the VB executable (the front end) to the C++ data access code. (This is really the whole point of the project, to learn how to work between the two languages). I am using an API call from the VB code to connect to C++. In C++, when I debug, the code runs to the last bracket (marked with ******) and then I get an Open File dialog asking me to "Please enter the path for CRTDLL.C". I have searched for this file on my machine. Its not there. I have searched MSDN and haven't come up with much that is helpful (some of it, I just don't understand).
Any help, no matter how rudimentary, will be appreciated.
CODE FOLLOWS:
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)<br />
{<br />
UNREFERENCED_PARAMETER(lpReserved);<br />
<br />
if (dwReason == DLL_PROCESS_ATTACH)<br />
{<br />
TRACE0("DATAACCESS.DLL Initializing!\n");<br />
<br />
if (!AfxInitExtensionModule(DataAccessDLL, hInstance))<br />
return 0;<br />
<br />
new CDynLinkLibrary(DataAccessDLL);<br />
}<br />
else if (dwReason == DLL_PROCESS_DETACH)<br />
{<br />
TRACE0("DATAACCESS.DLL Terminating!\n");<br />
AfxTermExtensionModule(DataAccessDLL);<br />
}<br />
CoUninitialize();<br />
return 1;
} ******
|
|
|
|
|
The debugger is trying to find source code for the _DllMainCRTStartup function, which is the actual DLL entry point function (it calls your DllMain after initialising the C Run-Time library). You can just press Cancel to get the debugger to continue.
It's probably doing this because you tried to Step Out of DllMain . Just choose Run when you get to the end of the function. If you do step out, but you haven't got the source, you'll land in a Disassembly window.
If you do want to see _DllMainCRTStartup , make sure you've installed the C Run-Time source code from the CD (by default, it's not installed) and browse to C:\Program Files\Microsoft Visual Studio\VC98\CRT\SRC (Visual C++ 6.0), C:\Program Files\Microsoft Visual Studio .NET\Vc7\crt\src (Visual Studio .NET 2002) or C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\crt\src (Visual Studio .NET 2003).
|
|
|
|
|
I have a program that requires a text file for it to function properly. I figured that it would be easiest for the user to not have to deal with the text file and just have it stored within the program. So is there a way to include a text file within a program and be able to read as if it was a text file? The file never needs to be changed so it seems like it's do-able. So can this be done?
I was accidentally looking at my own code and was thinking, "what is this guy doing?"
|
|
|
|
|
|
Import the text file into your project and give it a custom resource type, and name this resource whatever you want to. Then in your application you can use ::FindResource and ::LoadResource to copy the resource to a memory block and have full control over the memory. Bellow is a sample of how to do it.
DWORD CopyResToMem(UINT nResourceID, LPCTSTR lpResourceType, LPVOID lpBuffer, DWORD dwMaxBufferSize)
{
::ZeroMemory(lpBuffer, dwMaxBufferSize);
HRSRC hRs = ::FindResource(NULL, MAKEINTRESOURCE(nResourceID), lpResourceType);
if (hRs == NULL)
{
return 0;
}
HGLOBAL hGlb = ::Loadresource(NULL, hRs);
if (hGlb == NULL)
{
return 0;
}
LPVOID pData = ::LockResource(hGlb);
if (pData == NULL)
{
return 0;
}
const DWORD dwActualSize = min(dwMaxBufferSize, ::SizeofResource(NULL, hRs));
::memcpy(lpBuffer, pData, dwActualSize);
return dwActualSize;
}
Import your text file into your project, give it a custome resource type "TXT", and name this resource "MYTEXT". To retrieve the text file:
DWORD dwMyTextSize = 1000;
BYTE* pData = new BYTE[dwMyTextSize];
DWORD dwActual = CopyResToMem(MYTEXT, _T("TXT"), pData, dwMyTextSize);
ASSERT(dwActual > 0);
delete [] pData;
pData = NULL;
|
|
|
|
|
Thanks.
|
|
|
|
|
The one thing I did not like about this sample, is if your buffer is too small, you don't know how large to make it.
Perhaps you could SetLastError(ERROR_INSUFFICIENT_BUFFER) if the buffer size passed in was too small, so the client could determine that all the data was not obtained.
The memories of a man in his old age are the deeds of a man in his prime.
|
|
|
|
|
Well I was just giving the original hoster a rough idea on how to use a custome resource in his application, and of course the sample code were not perfect and he should change it a bit to fit his particular needs if he wants to employe the code pieces.
And yes, the issue you pointed out was existing, I did not address it in my post because I thought it'd better to leave things short and clear... hehe, anyway, we can do this:
DWORD GetResourceSize(UINT nResourceID, LPCTSTR lpResourceType)
{
HRSRC hRs = ::FindResource(NULL, MAKEINTRESOURCE(nResourceID), lpResourceType);
return ::SizeofResource(NULL, hRs);
}
Then in our application we should be able to allocate exact amount of memory needed.
DWORD dwMyTextSize = GetResourceSize(MYTEXT, _T("TXT"));
BYTE* pData = new BYTE[dwMyTextSize];
delete [] pData;
pData = NULL;
This should be better.
|
|
|
|
|
|
can I ask you how to validate a 'double' data type? I am taking a double data type to my edit control I want to check if the user input is a double type(not from the ddx.. some other way...) is there any other way to do this?
eg: like is_integer to validate integer type.. is there a way to validate a double type?
thnks
|
|
|
|
|
Take a look at the strtod function. You can probably get it to do what you want.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
but that's to convert string to a double.. I just want to check if the input value is a double..
thanks anyway...
|
|
|
|
|
OK if you really need some detailed ideas on validating a "double"... Let's see, a double should consist of three types of characters:
sign (+ or -), at most one, and, if any, must be the leading character.
point (.), at most one, must follow at least one digit, and must not be the last character.
digits (0-9), as many as there can be.
So here's an example:
BOOL IsDouble(LPCTSTR lpStr)
{
BOOL bHasPoint = FALSE;
const int LEN = _tcslen(lpStr);
for (int i = 0; i < LEN; i++)
{
if (lpStr[i] < _T('0') || lpStr[i] > _T('9'))
{
if (lpStr[i] == _T('+') || lpStr[i] == _T('-'))
{
if (i != 0)
{
return FALSE;
}
}
else if (lpStr[i] == _T('.'))
{
if (bHasPoint
|| i == 0
|| i == LEN - 1
|| (lpStr[i - 1] < _T('0') || lpStr[i - 1] > _T('9')))
{
return FALSE;
}
else
{
bHasPoint = TRUE;
}
}
else
{
return FALSE;
}
}
}
return TRUE;
}
Above code were typed directly in this reply and have not been tested in any compiler, so if there are any typo or errors I apologize, but I think this at least should partially answer your question.
|
|
|
|
|
Hi,
I am trying to figure out how to change the application icon at runtime, dynamically.
I know how to do for a given main window by calling
::SendMessage( hwnd_, WM_SETICON, ICON_BIG, (LPARAM)winIcon );
But while that changes it for the window, and in the start bar, it does NOT show up in the Task Manager, or in the alt/tab icon list. So How do I change those as well??
Thanks !
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
Does CWnd::SetIcon not work for you? I seem to remember that being the way to do it... heck, if you generate a dummy MFC dialog-based app, I think the dialog class comes with code that sets the icon as you speak of.
I'd look deeper, but I'm at my crummy box at home with no compiler.
Jim Crafton wrote:
¡El diablo está en mis pantalones! ¡Mire, mire!
Even though you've had sig that forever, it's still funny.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
Well I'm not using MFC, so I just use the SendMessage equivalent, but unfortunately all it changes is the window icon - the icon that shows in the Alt/Tab window is different (that's the one from the app's resource icon). I did some more digging but pretty much didn't find much other than to confirm that
::SendMessage( hwnd_, WM_SETICON, ICON_BIG, (LPARAM)winIcon );
works, but curiously if you use
::SendMessage( hwnd_, WM_SETICON, ICON_SMALL, (LPARAM)winIcon );
It doesn't make the change permanent - Wee what fun, the Win32 API is !
And they say size doesn't matter !
So for the moment I think I just give up and settle for changing the Window icon - better than nothing
Cheers
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
Probably you need to change the registered icon so try this:
SetClassLong(hWnd, GCL_HICON, (LONG) LoadIcon(hinst, MAKEINTRESOURCE(IDC_MYICON)));
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
My first working program was able to do that. It's not really hard.
I think it was SetIcon(HICON, BOOL). If you generated an MFC-based project, you'll find an example at the end of YourProjectDlg::InitDialog(), just before the TODO remark.
Somewhere in the code of your dialog (but I think it is also possible in SDIs or MDIs, but not how;P)(as long as it's in a function like YouProjectDlg::MemberFunction(...)) you put the following code:
m_hIcon = AfxGetApp->LoadIcon(IDI_Your_Icon);
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
I just copied it from OnInitDialog. I don't know what the function of the double execution of SetIcon is, but 'ey, it works, and that's what you want, don't you?
If you just want to show the small version of the icon (16x16), you should leave SetIcon(m_hIcon, FALSE); . (Why that one? That one actually means "Set the NON-big version of m_hIcon", since it's something like SetIcon (HICON TheIcon, BOOL BigIcon))
I stored the icon handle into m_hIcon, because that's the standard member variable to store the handle of the dialog's current icon (yes, of a dialog, also here I don't know anything about SDI/MDI stuff). But I don't think it will be harmful to use a local variable for that.
|
|
|
|
|
Hi,
I was opening a dialog with controls by left clicking on the parent window of my SDI application, but now I want my parent window to contain the dialog. That’s why in the CMyTreeView, I changed the constructor to the following
CMyTreeView::CMyTreeView() : CFormView(IDD_DIALOG1)
{
// TODO: add construction code here
}
where IDD_DIALOG1 is the dialog that I want in the CtreeView.
But, above doesn’t work, and I keep getting run time error at line CFormView::Create(..) in the file ViewForm.cpp
Can anyone tell me how I can convert my program, so that I can keep most of my codes unchanged (I’m doing all the processing in the dialog class and I don’t want to move them to the view class)
Please advise soon
Binayak
|
|
|
|
|
Does anybody have any information/links/etc about MFC classes CControlBar, CDockBar and CDockContext? On CodeProject, CodeGuru and other internet resources there are only few articles with obsolete information.
|
|
|
|
|