UpdateDriverForPlugAndPlayDevices returns ERROR_FILE_NOT_FOUND

Hi,
I am using the function UpdateDriverForPlugAndPlayDevices via the newdev.dll and it continuously receive Error 2 ERROR_FILE_NOT_FOUND. I looked on MSDN for their explanation of the what the error means and they say it means that the .inf file passed in for UpdateDriverForPlugAndPlayDevices’ third argument does not exist. I’ve looked at my file system and I am indeed passing in an .inf file that exists. I’ve tried using double backslashes in the path to .inf file thinking that I might be sending in a poorly formatted path but nothing seems to work. Thank you for any help.

Have you checked the setup API logs? They might provide a bit more insight
than “file not found” does.

-scott


Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com

wrote in message news:xxxxx@ntdev…
> Hi,
> I am using the function UpdateDriverForPlugAndPlayDevices via the
> newdev.dll and it continuously receive Error 2 ERROR_FILE_NOT_FOUND. I
> looked on MSDN for their explanation of the what the error means and they
> say it means that the .inf file passed in for
> UpdateDriverForPlugAndPlayDevices’ third argument does not exist. I’ve
> looked at my file system and I am indeed passing in an .inf file that
> exists. I’ve tried using double backslashes in the path to .inf file
> thinking that I might be sending in a poorly formatted path but nothing
> seems to work. Thank you for any help.
>

xxxxx@bauercontrols.com wrote:

I am using the function UpdateDriverForPlugAndPlayDevices via the newdev.dll and it continuously receive Error 2 ERROR_FILE_NOT_FOUND. I looked on MSDN for their explanation of the what the error means and they say it means that the .inf file passed in for UpdateDriverForPlugAndPlayDevices’ third argument does not exist. I’ve looked at my file system and I am indeed passing in an .inf file that exists. I’ve tried using double backslashes in the path to .inf file thinking that I might be sending in a poorly formatted path but nothing seems to work.

May I suggest you post the code? Another set of eyes can be a great
help in a case like this.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

I did check the setupapi.log and it offered no additional information, although I have seen other setupapi.logs when searching for this problem on the web and those seem to have information pertaining to UpdateDriver… that mine didn’t. That makes me a little curious. As to the code I am referencing the UpdateDriver… function in Inno Setup using an external command;

function device_drv_update(hwnd: Integer; hwID: String; infPath: String; instFlags: Integer; bReboot: Boolean): Boolean;
external ‘xxxxx@newdev.dll stdcall’;

Here is the procedure I call it from:
procedure dev_install_stg1(hwID: String; fileName: String);
var
phwnd, instFlags : Integer;
nResult: Integer;
infPath: String;
bReboot,rslt: Boolean;
temp, msg: String;

hwID =‘PCI\VEN_11B0&DEV_0200&SUBSYS_007111B0&REV_00’

begin

temp := ExpandConstant(‘{wizardhwnd}’);
phwnd := StrToInt(temp);

nResult := 1;
bReboot := True;
instFlags := 1;
infPath := ‘"’ + ExpandConstant('{app}\bin') + fileName + ‘"’;
rslt := device_drv_update(phwnd, hwID, infPath, instFlags, bReboot );
nResult := DLLGetLastError();

if ((rslt = FALSE ) and (nResult = ERROR_NO_SUCH_DEVINST )) then begin
msg := ‘Sending ’ + fileName + ’ to dev_install_stg2’;
MsgBox(msg,mbInformation,MB_OK);
dev_install_stg2(infPath);
end else if (rslt = TRUE) then begin
msg := 'Succeded updating driver ’ + fileName;
MsgBox(msg,mbInformation,MB_OK);
end else begin
MsgBox(‘Failed to update drivers’,mbError,MB_OK);
end;
end;
*****************************************************
I hope this sheds some light on it. Thanks for any help you can provide.

xxxxx@bauercontrols.com wrote:

I did check the setupapi.log and it offered no additional information, although I have seen other setupapi.logs when searching for this problem on the web and those seem to have information pertaining to UpdateDriver… that mine didn’t. That makes me a little curious. As to the code I am referencing the UpdateDriver… function in Inno Setup using an external command;

function device_drv_update(hwnd: Integer; hwID: String; infPath: String; instFlags: Integer; bReboot: Boolean): Boolean;
external ‘xxxxx@newdev.dll stdcall’;

Here is the procedure I call it from:
procedure dev_install_stg1(hwID: String; fileName: String);
var
phwnd, instFlags : Integer;
nResult: Integer;
infPath: String;
bReboot,rslt: Boolean;
temp, msg: String;

hwID =‘PCI\VEN_11B0&DEV_0200&SUBSYS_007111B0&REV_00’

begin

temp := ExpandConstant(‘{wizardhwnd}’);
phwnd := StrToInt(temp);

nResult := 1;
bReboot := True;
instFlags := 1;
infPath := ‘"’ + ExpandConstant('{app}\bin') + fileName + ‘"’;

The only time quotes are needed around a file name is when you are
creating a command line. When you are passing a string parameter to a
function, the beginning and ending of the file name are inherent in the
parameter itself. In this case, the quotes are almost certainly being
taken as part of the file name. Just use this:
infPath := ExpandConstant('{app}\bin') + fileName;


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

The external function command didn’t paste correctly in my previous post. The xxxxxxx part is replace by 'UpdateDriverForPlugAndPlayDevices

xxxxx@bauercontrols.com wrote:

The external function command didn’t paste correctly in my previous post. The xxxxxxx part is replace by 'UpdateDriverForPlugAndPlayDevices

I can explain that. The way you have to write that entry point for Inno
makes it look like an email address, and the forum interface shrouds
email addresses to protect from spam. Your code came through untouched
in the mailing list interface.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks for the heads up on the e-mail address mask.

As for removing the double quotes around the file path/name, when I do that I get an “Access violation at address 5F523855. Write of address 00000001” error and UpdateDriverForPlug… returns a 1 (Incorrect Function). Also, wouldn’t I need double quotes if ever the path to the file I was passing contained spaces? Thanks for the help.

xxxxx@bauercontrols.com wrote:

Thanks for the heads up on the e-mail address mask.

As for removing the double quotes around the file path/name, when I do that I get an “Access violation at address 5F523855. Write of address 00000001” error and UpdateDriverForPlug… returns a 1 (Incorrect Function).

5F523855 is the ASCII characters “U8R_”. Was that in the string somewhere?

Also, wouldn’t I need double quotes if ever the path to the file I was passing contained spaces? Thanks for the help.

Think about this logically. Where do the spaces matter? The only time
that the spaces are a problem are when you are trying to find the
beginning and ending of the file name, by parsing a command line or a
script. The name of the file does not include any quote marks. If I
have a file called
c:\My File Name.txt
then that is the name of the file. Now, if I need to type that file
name on a command line, I have to provide help:
copy c:\My File Name.txt copy.txt
That’s confusing, because “space” has an additional meaning in a command
line. Here, we use the quotes:
copy “c:\My File Name.txt” copy.txt
However, the copy command REMOVES the quotes before passing the name to
CreateFile.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

The explanation with regards to the double quotes makes sense indeed. Thank you.

The characters “U8R_” were not in the string being passed (C:\PCSTrans\bin\aafxpci.inf), but I miss-typed the actual address it was 5F52385C (or “\8R_”) , which also does not appear in the path. Thanks for the response.

Found out the issue. First, thanks for the information regarding the double quotes that did help out tremendously. Secondly, I was giving the last argument bBootRequired (optional and an output argument) in UpdateDriverForPlugAndPlayDevices an initial value before calling it. I removed the line bReboot := True and all is well. Thank you to everyone who responded.

I spoke to soon…does anyone know what error code -536870397 is for?

Err.exe is your friend (search for “Exchange Error-code Lookup Tool”. It is not really Exchange specific, so ignore that Exchange part of it.)

C:\>err -536870397

for decimal -536870397 / hex 0xe0000203

ERROR_NO_DRIVER_SELECTED setupapi.h

1 matches found for “-536870397”

  • S

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@bauercontrols.com
Sent: Tuesday, November 18, 2008 3:28 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] UpdateDriverForPlugAndPlayDevices returns ERROR_FILE_NOT_FOUND

I spoke to soon…does anyone know what error code -536870397 is for?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Get err.exe:

http://www.microsoft.com/downloads/details.aspx?familyid=be596899-7bb8-4208-b7fc-09e02a13696c&displaylang=en

Z:\>err E0000203

for hex 0xe0000203 / decimal -536870397 :

RND_NOT_CONNECTED rnderr.h
ERROR_NO_DRIVER_SELECTED setupapi.h

2 matches found for “E0000203”

-scott


Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com

wrote in message news:xxxxx@ntdev…
>I spoke to soon…does anyone know what error code -536870397 is for?
>

That’s awesome…thanks so much Ken and Scott.