|
Donguy1976 wrote: What other possible causes can lead to DeleteFile() to fail? If the call fails then you can find the reason by calling GetLastError() , as described in the documentation[^].
Use the best guess
|
|
|
|
|
From the MSDN documentation of DeleteFile:
If the function fails, the return value is zero (0). To get extended error information, call GetLastError.
GetLastError returns an error code which you can convert into a string via the FormatMessage function. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms680582%28v=vs.85%29.aspx[^] for an example. One possible reason might be that you are trying to delete the same file more than once.
|
|
|
|
|
Donguy1976 wrote: What other possible causes can lead to DeleteFile() to fail?
Well, the blindingly obvious are:
1) It doesnt exist.
2) Somthing else has it open.
The less obvious is that your calling code doesnrt have Delete authorisation.
Loo ak the error return, it will tell you all about it.
|
|
|
|
|
Hi,
I created a source filter and is registered successfuly. Every time I use GraphEdit it works fine but when I try to use under MFC/C++ CoCreateInstance fails as not registered (error 0x80040154).
hr = CoCreateInstance(CLSID_PIAsyncFile, NULL,CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pAsync);
I tried again and again with regsvr32 and successfully registers the filter.
What seems to be wrong here?
I use 32Bit debug builds, on Win7 64bit system.
Regards,
sdancer75
|
|
|
|
|
Make sure you've called CoInitialize or CoInitializeEx properly before calling CoCreateInstanc e.
|
|
|
|
|
Thanks,
I have called the
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
at the class construction and
CoUninitialize();
at the destruction.
Any other filter is successfully CoCreateInstance except my filter.
sdancer75
|
|
|
|
|
Get the error returned in hr and use the Error Lookup tool check what the error is.
|
|
|
|
|
Hi,
As you can see in question at the very begging, the error code is 0x80040154 which means "class is not registered"
This is strange since the class is indeed registered at sysWOW3264 (a mirror registry for 32-bit windows apps running on 64bit windows) since my source filter is 32-bit.
Under ms filter graph, I can find and use successfully the filter, but the problem still exists under my MFC project.
PS:In my stdafx.h I declare my filter as follows
#include "INITGUID.H"
DEFINE_GUID(CLSID_PIAsyncFile,
0x8576CEC8, 0x964D, 0x4B51, 0xAC, 0x45, 0x2B, 0x24, 0xDE, 074, 0x8E, 0x23);
Thanx
sdancer75
|
|
|
|
|
Sorry, I didn't notice the error code you posted in your question.
I'm assuming that the MFC project is built as a 32-bit application.
One more thing you can try -
There are both 32-bit and 64-bit versions of regsvr32.exe available in %SystemRoot%\Windows\System32 and %Systemroot%\Windows\SysWOW64.
Try registering the component with either of the 2 and check if the MFC application is able to find it.
|
|
|
|
|
Thanks,
Yes I know and I already tried both versions of regsvr32 (32 & 64 Bit) but still does not work.
Regards,
sdancer75
|
|
|
|
|
All I can think of is that the COM component uses some dependency files like DLLs that GraphEdit is able to find but the MFC application is not.
Does the COM component reside is some folder along with other dependency files.
If so, you can either try to copy the EXE to that folder or change the working directory using the SetCurrentDirectory API.
|
|
|
|
|
I am not sure about that.... The filter resides is a local folder and not in windows subfolder and is a "debug build". I will try to move the filter inside the C:\windows\SysWOW64 and register again.
sdancer75
|
|
|
|
|
|
Finally Solved ! A tiny error at the CLSID declaration !
sdancer75
|
|
|
|
|
Can you please tell me what is the small fix from CLSID declaration?Even i am suffering with this class not registered problem
|
|
|
|
|
Not fix at all, just a typing error in my CLID declaration. What error do you get ?
sdancer75
|
|
|
|
|
Hello there,
If i call DeleteFile on a file that's pretty large, does the function wait until the entire file is deleted before returning?
Or does it return immediately? i.e., the control is passed to OS to complete the task of deletion and then return immediately?
For e.g., if i am deleteing 5 files inside a loop and 2 of them happen to be larger size, will it wait until each file is completely deleted before going to the next one?
If it doesn't, then there's a probability that when the next file is called by DeleteFile the previous one might still be in the process of deletion and it could fail.
Is there a possibility like that?
|
|
|
|
|
From the documentation I'm guessing that it will not return immediately, accurate return codes require the operation to complete. Yikes! Note to self...read the whole thing first! sorry.
modified 3-Jul-13 14:27pm.
|
|
|
|
|
As far as I know, the function returns immediately and the deletion occurs in the background. This is always true if the file is still opened (see DeleteFile[^] in the MSDN):
Quote: The DeleteFile function marks a file for deletion on close. Therefore, the file deletion does not occur until the last handle to the file is closed. Overall, there should be no significant difference in time for large and small files because the file data itself are left unchanged on the disk. Only the directory entries are touched.
|
|
|
|
|
Hello!!! I'm learning C language and trying to make a calculator. Here's the code:
#include <stdio.h>
int main()
{
int a, b, add, sub, mul;
float div;
char choice='y';
do {
printf("Enter any choice:\n1. Addition(a)\n2. Subtraction(b)\n3. Multiplication(c)\n4. Division(d)\n5. Exit(x)");
scanf("%c", &choice);
switch(choice)
{
case 'a':
{printf("Enter any two numbers:");
scanf("%d %d",&a, &b);
add = a + b;
printf("Sum: %d\n", add);
break;}
case 'b':
printf("Enter any two numbers:");
scanf("%d %d",&a, &b);
sub = a - b;
printf("Difference: %d\n", sub);
break;
case 'c':
printf("Enter any two numbers:");
scanf("%d %d",&a, &b);
mul = a * b;
printf("Product: %d\n", mul);
break;
case 'd':
printf("Enter any two numbers:");
scanf("%d %d",&a, &b);
div = a / b;
printf("Quotient: %f\n", div);
break;
case 'x':
break;
}
}while(choice!='x');
return 0;
}
The problem is that it is not looking very good. I'll be very thankful if anyone could help.
|
|
|
|
|
anasshad wrote: I'll be very thankful if anyone could help. I would suggest spending some time looking through the beginners section articles[^] for ideas and examples.
Use the best guess
|
|
|
|
|
Does it compile ?
Does it crash ?
Does it give wrong answer ?
Are you able to read numbers from the user ? (outside of this example?)
Have you tried debugging ?
Nihil obstat
|
|
|
|
|
For a calculator the probable way to have it look would be like the keypad on a calculator, but as you're just starting that's a bit of a jump. As a first step why not try a Window or Dialog with two Edit boxes for the numbers and buttons to select +, - etc. The articles here will help with that as already mentioned.
|
|
|
|
|
anasshad wrote: The problem is that it is not looking very good. Meaning what exactly?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Hi,
I have a slider control on a dialog box. I am playing a video file and slider moves according to the video elapsed. Suppose I have set the slider range to 100. Now till some point say 90, the slider moves to the point wherever I click the mouse. but at the last point in between some range say 90 - 100 (to the end of the slider), if I click the mouse button anywhere, slider jumps to the end.
I am using a TimeLine control where user can add more than 1 video (1, 2, 4, 8, 10 , 50 etc......), If I use only one video, slider moves as per the video progression.....Issue arises when I add more than 1 video and click on the start button, slider starts moving....Now when I drag the slider to any position or I click the mouse button anywhere on the slider control, slider thumb moves to that position and immediately jumps back to some other position. This is the Issue, I am facing.
Can anybody share some sample code where slider is moving with the video showing the progress of the video.
I want to implement a functionality similar to VLC player. Wherever user clicks the mouse, slider moves to that point.
Any help will be appreciated.
Regards,
Mbatra
modified 3-Jul-13 9:15am.
|
|
|
|