|
Could be that you don't have the necessary permissions / authority to change the attribute.
Look at the value returned by SetFileAttributes - that may give you an idea why the call did not do what you expected.
|
|
|
|
|
I am the administrator of my machine so permissions shouldn't be a problem. The SetFileAttributes(filename, FILE_ATTRIBUTE_NORMAL) returns 0. Am I missing something?
|
|
|
|
|
Nevermind. It works. Thanks for all your help.
|
|
|
|
|
So, don't keep us all in suspense.
What was the problem, and what was the solution?
|
|
|
|
|
Sorry...it was just my stupidity in changing the wrong file. Instead of changing the destination file's attributes, I changed the source file's.
|
|
|
|
|
Ah, I guess we will have to watch out for the same problem!
Thanks.
|
|
|
|
|
elephantstar wrote:
Instead it returns a value of 33.
Which is a combination of FILE_ATTRIBUTE_ARCHIVE and FILE_ATTRIBUTE_READONLY .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello y'all,
Does one need Microsoft SDK to make a media player (say, for .AVI, .WMV, .MPG, etc.) or any particular headers/libraries? I'm used to Visual C++.
I thought I knew everything I needed to know to build a media player with my own interface design, but I'm a bit in the dark here.
Thanks in advance for helping me out, peeps.
Signed,
s9928863.
|
|
|
|
|
You want to write a media player from scratch, or use DirectShow, or use the Windows Media Player via COM ?
There are a lot of Microsoft SDKs, there is one for DirectX ( which is hte obvious one to use ), a Platform SDK ( useful esp if you have VC6 ), and many more.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm responsible for the development of a test application for a type of USB device. These devices sometimes need to reenumerate, for example when transitioning from firmware download to active mode. The device driver enumerates at \\.\<ourdev>USB-0 for the first device, \\.\<ourdev>USB-1 for the second device inserted and so on. But when multiple devices reenumerate simultaneously (happens when an automated test setup toggles the reset line on all devices) the order in which they reenumerate is not deterministic. That's dealt with by releasing the devices from reset sequentially, but I am trying to satisfy a feature request that the transport identifier used internally in the test application remain constant for a given serial number; basically the transport identifiers 'usb0', 'usb1' etc would be mapped to device paths \\.\<ourdev>USB-n using the devices' serial numbers.
Problem: I've been combing MSDN Library > Win32 and COM Development > System Services > Device I/O > SDK Documentation > Device I/O, especially the Device Management section in there, and I can't find any mention of obtaining serial numbers. A search of the whole MSDN library for "USB serial number" turned up lots and lots of unrelated hits, but nothing for how to get the serial number for a USB device.
Does anyone know how to do that? I know it ends up in the registry as a part of the plug and play device ID, but that would only be useful if there was a way to identify the registry entry for a given \\.\<ourdev>USB-n device path...
|
|
|
|
|
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
|
|
|
|