|
For being able to do that, you will need to work at the driver level. In fact, what is happening is that when you plug your USB device, the OS will 'ask' for it's ProductID and VendorID then look in all the inf files and look for the corresponding entry in one file (in summary...). In this file there is a match with the driver the OS need to load. And it's this driver that provides you the string with wich you open your USB device from an upper-level application (in fact, when you open your device in your application with CreateFile, you access the driver, not the device directly).
Thus, inside your driver you'll need to change the code to be able to associate the 'opening string' (\\.\USB-X) with a specific device. But there, I don't know exactly hoz you can do that... You will need to read a little bit nore informations about drivers
Hope this helps
|
|
|
|
|
I am trying to dynamically load MPR.DLL and use WNetGetUserA in a dialog-based app.
Here's my code:
typedef DWORD (*LPDLLUSER_FUNC)(LPCTSTR,LPTSTR,LPDWORD);
char name[MAX_PATH]="";
DWORD size=MAX_PATH;
HINSTANCE hLib=LoadLibraryEx("mpr.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (hLib)
{
LPDLLUSER_FUNC lpDllEntryPoint = (LPDLLUSER_FUNC) GetProcAddress(hLib,"WNetGetUserA");
if (lpDllEntryPoint)
{
DWORD ret=(*lpDllEntryPoint)(NULL,name,&size);
char buf[10];
_itoa( ret, buf, 10 );
AfxMessageBox(buf);
AfxMessageBox(name);
}
FreeLibrary(hLib);
}
I get the following error:
"The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."
I assume my LPDLLUSER_FUNC define is wrong. But WNetGetUserA has the same definition.
Any ideas what to do here? Linking statically to MPR.LIB is unfortunatelly not an option.
|
|
|
|
|
try this:
typedef DWORD (WINAPI *LPDLLUSER_FUNC)(LPCTSTR,LPTSTR,LPDWORD);
/cadi
24 hours is not enough
|
|
|
|
|
Hi,
I have a simple question. I copied the following code into my own subclass of CFrameWnd:
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_IMAGEVIEWER_TOOLBAR))
{
TRACE0("Failed to create first main toolbar\n");
return -1;
}
The toolbar shows up but all the buttons are disabled. I did not want to write UPDATE_COMMAND_UI handler for each button because I never plan on disabling most (if not all of them). What am I missing from my code? For any SDI app you create in the wizard the toolbar shows up with buttons enabled. I copied the same code and it doesn't work for me.
Thanks.
|
|
|
|
|
You have to have code to handle the command generated by a click on the button. If there is no code in your program to handle the click, the button will be disabled.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
|
In my application I have the following which opens a SHOUTcast stream and plays it.
In order to use the function OpenURL(LPVOID pParam) it has to be static or not a member of my class. The problem is that I want to have the OpenURL function set values that are members of my class.
For example my class has a variable called:
CString StreamName;
So I call the following line of code.
AfxBeginThread( OpenURL, _param );
I want OpenURL to set the value of StreamName.
If OpenURL is not a member of the class it doesn't know StreamName.
If OpenURL is a static member of the class then StreamName has to be static ( not sure how to deal with that)
I can't make OpenURL a friend of the class because I would have to pass in the class object and the threadproc must have a param list of ( LPVOID pParam )
How do I get around this problem?
|
|
|
|
|
There's many ways to do this. One is to pass the pointer to the object and another is to have a global pointer to the object.
|
|
|
|
|
You could also encapsulate your thread function in a class whose constructor takes the instance of the object. Anyway, as you can see there's all kinds of ways and which you choose really depends on a lot of specifics about your code.
|
|
|
|
|
Thanks I will try these ideas
|
|
|
|
|
See here and here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Overwhelming response many thanks.
|
|
|
|
|
Hello,
This[^] very nice class should fit all your needs..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
|
there is not open mode in fstream(ios) for creating a new file if the given file doesnt exist. how could I do that?
thanks
|
|
|
|
|
Doesn't that happen by default? Check out the fstream constructor's documentation.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I dont think so, since I have tried , it donesnt work. and little information on fstream in msdn.
you have any idea?
thanks
|
|
|
|
|
heng0987 wrote:
I dont think so, since I have tried , it donesnt work.
What does your code look like? This works fine for me:
fstream ff("c:\\david.txt", ios::out);
ff << 123;
ff.close(); heng0987 wrote:
...and little information on fstream in msdn.
Really?[^]
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
could you plz tell me in complete details how can i call matlab functions from a c++ program .
NOTE: ( i've already tried using engine.h but i got an error telling me" unresolved external symbol _engopen")
gobar
|
|
|
|
|
Did you include the lib that contains engopen?
Check this directory for some of the libraries that you need to link.
<matlab path="">\extern\lib\win32\microsoft\msvc60
|
|
|
|
|
i have created an SDI MFC app. How do i get it to check its own location on the hard-drive and spit back the path? IS there a path property for the executable?
thanks
|
|
|
|
|
GetModuleFileName(NULL, ...)
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
TCHAR buff[MAX_PATH];
GetModuleFileName(NULL, buff, MAX_PATH);
char drive[3];
char dir[MAX_PATH];
char fname[MAX_PATH];
char ext[MAX_PATH];
_splitpath(buff, drive, dir, fname, ext);
|
|
|
|
|
You may find this code intresting
CString strTmp,strDirectory;
GetModuleHandle(NULL,strTmp.GetBuffer(MAX_PATH),MAX_PATH);
strTmp.ReleaseBuffer();
strDirectory=strTmp.Left(strTmp.ReverseFind('\\'));
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Does anyone know what needs done to get the project built in Release mode.
Debug build is OK.
SSIC_Example error LNK2005: "class _AFX_THREAD_STATE * __stdcall AfxGetThreadState(void)" (?AfxGetThreadState@@YGPAV_AFX_THREAD_STATE@@XZ) already defined in mfc71.lib(MFC71.DLL)
SSIC_Example error LNK2005: "class AFX_MODULE_STATE * __stdcall AfxGetModuleState(void)" (?AfxGetModuleState@@YGPAVAFX_MODULE_STATE@@XZ) already defined in mfc71.lib(MFC71.DLL)
SSIC_Example error LNK2005: "class CWinThread * __stdcall AfxBeginThread(unsigned int (__cdecl*)(void *),void *,int,unsigned int,unsigned long,struct _SECURITY_ATTRIBUTES *)" (?AfxBeginThread@@YGPAVCWinThread@@P6AIPAX@Z0HIKPAU_SECURITY_ATTRIBUTES@@@Z) already defined in mfc71.lib(MFC71.DLL)
SSIC_Example error LNK2005: "class CWinThread * __stdcall AfxGetThread(void)" (?AfxGetThread@@YGPAVCWinThread@@XZ) already defined in mfc71.lib(MFC71.DLL)
SSIC_Example error LNK2005: "int __stdcall AfxMessageBox(char const *,unsigned int,unsigned int)" (?AfxMessageBox@@YGHPBDII@Z) already defined in mfc71.lib(MFC71.DLL)
SSIC_Example error LNK2005: "protected: class CFrameWnd * __thiscall CCmdTarget::GetRoutingFrame(void)" (?GetRoutingFrame@CCmdTarget@@IAEPAVCFrameWnd@@XZ) already defined in mfc71.lib(MFC71.DLL)
i.e. what setting have I forgot to change in Release mode.
|
|
|
|