473,799 Members | 3,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with SetupInstallFro mInfSection

I was hoping someone could help me get SetupInstallFro mInfSection
working properly. I'm trying to start in install section in a driver
INF (hal.inf specifically). I'm doing this in C#, but I also tried it
in C++ with (MOSTLY) the same
parameters and got the same error, which is 1004 (Invalid Flags).
Here's my C# code that I'm using. Any help would be MOST appreciated.

using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Runtime. InteropServices ;
using System.IO;

namespace UIUHWScan.Class es
{
public class UpdateHAL
{
#region Constants

const int INF_STYLE_NONE = 0;
const int INF_STYLE_OLDNT = 1;
const int INF_STYLE_WIN4 = 2;

//
// Flags for SetupInstallFro mInfSection
//
const uint SPINST_LOGCONFI G =0x00000001;
const uint SPINST_INIFILES = 0x00000002;
const uint SPINST_REGISTRY = 0x00000004;
const uint SPINST_INI2REG = 0x00000008;
const uint SPINST_FILES = 0x00000010;
const uint SPINST_BITREG = 0x00000020;
const uint SPINST_REGSVR = 0x00000040;
const uint SPINST_UNREGSVR = 0x00000080;
const uint SPINST_PROFILEI TEMS = 0x00000100;

const uint SPINST_COPYINF = 0x00000200;
const uint SPINST_ALL = 0x000003ff;

const uint SPINST_SINGLESE CTION = 0x00010000;
const uint SPINST_LOGCONFI G_IS_FORCED = 0x00020000;
const uint SPINST_LOGCONFI GS_ARE_OVERRIDE S = 0x00040000;
const uint SPINST_REGISTER CALLBACKAWARE = 0x00080000;
const uint SPINST_DEVICEIN STALL = 0x00100000;

//
// CopyStyle values for copy and queue-related APIs
//
const uint SP_COPY_DELETES OURCE = 0x0000001; // delete
source file on successful copy
const uint SP_COPY_REPLACE ONLY = 0x0000002; // copy only if
target file already present
const uint SP_COPY_NEWER = 0x0000004; // copy only if source
newer than or same as target
const uint SP_COPY_NEWER_O R_SAME = SP_COPY_NEWER;
const uint SP_COPY_NOOVERW RITE = 0x0000008; // copy only if
target doesn't exist
const uint SP_COPY_NODECOM P = 0x0000010; // don't decompress
source file while copying
const uint SP_COPY_LANGUAG EAWARE = 0x0000020; // don't
overwrite file of different language
const uint SP_COPY_SOURCE_ ABSOLUTE = 0x0000040; //
SourceFile is a full source path
const uint SP_COPY_SOURCEP ATH_ABSOLUTE = 0x0000080; //
SourcePathRoot is the full path
const uint SP_COPY_IN_USE_ NEEDS_REBOOT = 0x0000100; //
System needs reboot if file in use
const uint SP_COPY_FORCE_I N_USE = 0x0000200; // Force target-
in-use behavior
const uint SP_COPY_NOSKIP = 0x0000400; // Skip is disallowed
for this file or section
const uint SP_FLAG_CABINET CONTINUATION = 0x0000800; // Used
with need media notification
const uint SP_COPY_FORCE_N OOVERWRITE = 0x0001000; // like
NOOVERWRITE but no callback nofitication
const uint SP_COPY_FORCE_N EWER = 0x0002000; // like NEWER
but no callback nofitication
const uint SP_COPY_WARNIFS KIP = 0x0004000; // system
critical file: warn if user tries to skip
const uint SP_COPY_NOBROWS E = 0x0008000; // Browsing is
disallowed for this file or section
const uint SP_COPY_NEWER_O NLY = 0x0010000; // copy only if
source file newer than target
const uint SP_COPY_RESERVE D = 0x0020000; // was:
SP_COPY_SOURCE_ SIS_MASTER (deprecated)
const uint SP_COPY_OEMINF_ CATALOG_ONLY = 0x0040000; //
(SetupCopyOEMIn f only) don't copy INF--just catalog
const uint SP_COPY_REPLACE _BOOT_FILE = 0x0080000; // file
must be present upon reboot (i.e., it's
// needed by
the loader); this flag implies a reboot

const long HKEY_LOCAL_MACH INE = 0x80000002L;

//
// Operation/queue start/end notification. These are ordinal
values.
//
const uint SPFILENOTIFY_ST ARTQUEUE =0x00000001;
const uint SPFILENOTIFY_EN DQUEUE =0x00000002;
const uint SPFILENOTIFY_ST ARTSUBQUEUE =0x00000003;
const uint SPFILENOTIFY_EN DSUBQUEUE =0x00000004;
const uint SPFILENOTIFY_ST ARTDELETE =0x00000005;
const uint SPFILENOTIFY_EN DDELETE =0x00000006;
const uint SPFILENOTIFY_DE LETEERROR =0x00000007;
const uint SPFILENOTIFY_ST ARTRENAME =0x00000008;
const uint SPFILENOTIFY_EN DRENAME =0x00000009;
const uint SPFILENOTIFY_RE NAMEERROR =0x0000000a;
const uint SPFILENOTIFY_ST ARTCOPY =0x0000000b;
const uint SPFILENOTIFY_EN DCOPY =0x0000000c;
const uint SPFILENOTIFY_CO PYERROR =0x0000000d;
const uint SPFILENOTIFY_NE EDMEDIA =0x0000000e;
const uint SPFILENOTIFY_QU EUESCAN = 0x0000000f;

const uint SPFILENOTIFY_FI LEINCABINET = 0x00000011; // The
file has been extracted from the cabinet.
const uint SPFILENOTIFY_NE EDNEWCABINET = 0x00000012; // file
is encountered in the cabinet.
const uint SPFILENOTIFY_FI LEEXTRACTED = 0x00000013; // The
current file is continued in the next cabinet.
const uint NO_ERROR = 0;

#endregion

#region Delegates

public delegate uint PSP_FILE_CALLBA CK(uint context, uint
notifaction,
IntPtr param1, IntPtr param2);

#endregion

#region DLL Imports

[DllImport("setu papi.dll", SetLastError = true, CharSet =
CharSet.Unicode )]
private static extern bool SetupInstallFro mInfSection(Int Ptr
owner,
IntPtr infHandle, string sectionName, uint flags, IntPtr
hKey,
IntPtr sourceRootPath, uint copyFlags, PSP_FILE_CALLBA CK
msgHandler,
ref uint context, IntPtr deviceInfoSet, IntPtr
deviceInfoData) ;

[DllImport("setu papi.dll", SetLastError = true)]
public static extern IntPtr SetupOpenInfFil e(
string FileName,
IntPtr InfClass,
int InfStyle,
int ErrorLine
);

[DllImport("setu papi.dll", SetLastError = true)]
public static extern void SetupCloseInfFi le(
IntPtr InfHandle
);

#endregion

/// <summary>
/// The FileCallback callback function is used by a number of
the setup functions. The PSP_FILE_CALLBA CK type defines a pointer to
this callback function. FileCallback is a placeholder for the
application-defined function name.
/// Platform SDK: Setup API
/// </summary>
private uint CallBack(uint context, uint notification, IntPtr
param1, IntPtr param2)
{
uint rtnValue = NO_ERROR;
Console.WriteLi ne("CallBack: Context = {0}, Notifacation =
{1}",
context, notification);
return rtnValue;
}

public bool InstallSection( )
{
string windowsFolder =
Environment.Get EnvironmentVari able("WINDIR");
string halINF = Path.Combine(wi ndowsFolder, @"inf
\hal.inf");
IntPtr hInf = SetupOpenInfFil e(halINF, IntPtr.Zero,
INF_STYLE_WIN4, 0);
if (hInf == (IntPtr)(-1))
{
int err = Marshal.GetLast Win32Error();
Console.WriteLi ne("Invalid INF File: {0}", halINF);
return false;
}
try
{
string installSection = "E_ISA_UP_H AL";
bool iResult = false;
PSP_FILE_CALLBA CK callback = new
PSP_FILE_CALLBA CK(CallBack);
uint context = 0;
unchecked
{
SetupInstallFro mInfSection(Int Ptr.Zero, hInf,
installSection,
SPINST_ALL, new
IntPtr((int)HKE Y_LOCAL_MACHINE ), IntPtr.Zero,
SP_COPY_FORCE_I N_USE, callback, ref context,
IntPtr.Zero, IntPtr.Zero);
}
if (!iResult)
{
int err = Marshal.GetLast Win32Error();
Console.WriteLi ne("Error : {0}",
err.ToString("x "));
return false;
}
Console.WriteLi ne("Successfull !");
}
finally
{
SetupCloseInfFi le(hInf);
}

return true;
}
}
}
Oct 28 '08 #1
3 3892
Rymfax <cw*****@bigban gllc.comwrote:
>
I was hoping someone could help me get SetupInstallFro mInfSection
working properly. I'm trying to start in install section in a driver
INF (hal.inf specifically).
What's the point of this? If you have an EISA machine, this should be done
automatically. If not, what good is it going to do to install an EISA
section?
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Oct 29 '08 #2
On Oct 29, 12:11*am, Tim Roberts <t...@probo.com wrote:
Rymfax <cwal...@bigban gllc.comwrote:
I was hoping someone could help me get SetupInstallFro mInfSection
working properly. *I'm trying to start in install section in a driver
INF (hal.inf specifically).

What's the point of this? *If you have an EISA machine, this should be done
automatically. *If not, what good is it going to do to install an EISA
section?
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
My application needs to be able to do this. From the stand-point of
the help I need, the section of the INF that I need to install
probably doesn't matter. The fact still remains that I can't seem to
get it to work. Do you think you could provide me with an example of
how to use SetupInstallFro mInfSection? Or is there another way to
execute a particular install section from an INF to update the driver
on a device? UpdateDriverFor PlugAndPlayDevi ces() won't work for me
because I want to execute a section that may not be the "best choice"
for the driver.

I'd really, REALLY appreaciate the thelp because I'm stuck and
frustrated.
Oct 30 '08 #3
Rymfax <cw*****@bigban gllc.comwrote:
>
My application needs to be able to do this. From the stand-point of
the help I need, the section of the INF that I need to install
probably doesn't matter. The fact still remains that I can't seem to
get it to work. Do you think you could provide me with an example of
how to use SetupInstallFro mInfSection?
From C#? No.

In my own personal opinion, people trying to do SetupDi things from C# are
really just hurting themselves. The APIs are verbose and complicated. My
advice is to write this in unmanaged code.

I'm sure you understand that free advice is worth every penny that it
costs...
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Oct 31 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
6563
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help Workshop program: hcw.exe that's included with Visual Basic. This exact same file compiled perfectly with no notes, warnings or errors prior to reformatting my system. Prior to the reformatting, I copied the help.rtf file onto a CD and checked the box to...
6
4356
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing result in any way. Who can help me, I thank you very very much. list.cpp(main program) //-------------------------------------------------------------------------- - #pragma hdrstop #pragma argsused
3
3368
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With numarray, help gives unhelpful responses:
7
5393
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available from clicking on many of the available topics (mostly methods but some properties are also unavailable). This same problem occurs with many, if not most, keywords. Is there any way I can activate these "missing" help topics? HELP!
5
3288
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time using "F1" help within the VB IDE. Is this expectation achievable In trying to test my help file in the IDE, I have a solution with 2 projects: the DLL and a tester. VB does not look for my help file; instead, it looks for path to my source code...
8
3238
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both including search the internet for help, but the help is worthless. Any ideas?
10
3369
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably the worst I ever seen. I almost cannot find anything I need, including things I
1
6142
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve default property of object Label. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"' Label = New Object(){Box1, Box2, Box3, Box4, Box5, Box6, Box7, Box8, Box9, Box10, Box11,...
0
262
by: Rymfax | last post by:
I was hoping someone could help me get SetupInstallFromInfSection working properly. I'm trying to start in install section in a driver INF (hal.inf specifically). I'm doing this in C#, but I also tried it in C++ with (MOSTLY) the same parameters and got the same error, which is 1004 (Invalid Flags). Here's my C# code that I'm using. Any help would be MOST appreciated. using System; using System.Collections.Generic; using System.Text;
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10247
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10214
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9067
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7561
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.