Elektroda.pl
Elektroda.pl
X
Serwerowe OpowieściSerwerowe Opowieści
Proszę, dodaj wyjątek dla www.elektroda.pl do Adblock.
Dzięki temu, że oglądasz reklamy, wspierasz portal i użytkowników.

Jak w c++ zainstalować sterowniki z poziomu BCB.

17 Sie 2007 10:43 1373 2
  • Poziom 12  
    Witam, piszę program do obsługi modułu FT232BM. Mam problem z napisaniem części instalującej sterowniki.
    Znajduja się one tutaj: http://ftdichip.com/Drivers/CDM/CDM%202.02.04%20WHQL%20Certified.zip
    Jak je zainstalować z poziomu C++? (BCB6)
    próbowałem uzywać polecenia ShellExecute() z parametrami "install","import", dla plików .inf , lecz bez skutku. Pojawia sie klepsydra nad formularzem, lecz w systemie nie ma żadncyh zmian.

    Prosze o pomoc.
    Pozdrawiam.
  • Serwerowe OpowieściSerwerowe Opowieści
  • Poziom 12  
    Doszedłem do funkcji SetupInstallFile:
    Cytat:
    SetupInstallFile

    The SetupInstallFile function installs a file as specified either by an INFCONTEXT returned by SetupFindXXXLine or explicitly by the filename and path information.

    If a file is copied, the caller of this function is required have privileges to write into the target directory.


    BOOL SetupInstallFile(
    HINF InfHandle,
    PINFCONTEXT InfContext,
    PCTSTR SourceFile,
    PCTSTR SourcePathRoot,
    PCTSTR DestinationName,
    DWORD CopyStyle,
    PSP_FILE_CALLBACK CopyMsgHandler,
    PVOID Context
    );

    Parameters
    InfHandle
    Optional pointer to the handle to an INF file that contains SourceDisksNames and SourceDisksFiles sections. If platform-specific sections exist for the user's system (for example, SourceDisksNames.x86 and SourceDisksFiles.x86), the platform-specific section will be used. If InfContext is NULL and CopySyle includes SP_COPY_SOURCE_ABSOLUTE or SP_COPY_SOURCEPATH_ABSOLUTE, InfHandle is ignored.
    InfContext
    Optional pointer to the context of a line in a Copy Files section in an INF file. The routine looks this file up in the SourceDisksFiles section of InfHandle to get file copy information. If InfContext is not specified, SourceFile must be.
    SourceFile
    Optional pointer to the file name (no path) of the file to copy. The file is looked up in the SourceDisksFiles section. The SourceFile parameter must be specified if InfContext is not, and is ignored if InfContext is specified.
    SourcePathRoot
    Optional poitner to the root path for the file to be copied (for example, A:\ or F:\). Paths in the SourceDisksNames section are appended to this path. The SourcePathRoot parameter is ignored if CopyStyle includes the SP_COPY_SOURCE_ABSOLUTE flag.
    DestinationName
    Optional pointer to the file name only (no path) of the target file. This parameter can be NULL to indicate that the target file should have the same name as the source file. If InfContext is not specified, DestinationName supplies the full target path and filename for the target.
    CopyStyle
    Flags that control the behavior of the file copy operation. These flags may be a combination of the following values.

    SP_COPY_DELETESOURCE
    Delete the source file upon successful copy. The caller is not notified if the delete fails.
    SP_COPY_REPLACEONLY
    Copy the file only if doing so would overwrite a file at the destination path. If the target doesn't exist, the function returns FALSE and GetLastError returns NO_ERROR.
    SP_COPY_NEWER_OR_SAME
    Examine each file being copied to see if its version resources indicate that it is either the same version or not newer than an existing copy on the target.
    The file version information used during version checks is that specified in the dwFileVersionMS and dwFileVersionLS members of a VS_FIXEDFILEINFO structure, as filled in by the version functions. If one of the files does not have version resources, or if they have identical version information, the source file is considered newer.

    If the source file is not newer or equal in version, and CopyMsgHandler is specified, the caller is notified and may cancel the copy. If CopyMsgHandler is not specified, the file is not copied.

    SP_COPY_NEWER_ONLY
    Examine each file being copied to see if its version resources indicate that it is not newer than an existing copy on the target. If the source file is newer but not equal in version to the existing target, the file is copied.
    SP_COPY_NOOVERWRITE
    Check whether the target file exists, and, if so, notify the caller who may veto the copy. If CopyMsgHandler is not specified, the file is not overwritten.
    SP_COPY_NODECOMP
    Do not decompress the file. When this flag is set, the target file is not given the uncompressed form of the source name (if appropriate). For example, copying f:\x86\cmd.ex_ to \\install\temp results in a target file of \\install\temp\cmd.ex_. If the SP_COPY_NODECOMP flag was not specified, the file would be decompressed and the target would be called \\install\temp\cmd.exe. The filename part of DestinationName, if specified, is stripped and replaced with the filename of the source file. When SP_COPY_NODECOMP is specified, no language or version information can be checked.
    SP_COPY_LANGUAGEAWARE
    Examine each file being copied to see if its language differs from the language of any existing file already on the target. If so, and CopyMsgHandler is specified, the caller is notified and may cancel the copy. If CopyMsgHandler is not specified, the file is not copied.
    SP_COPY_SOURCE_ABSOLUTE
    SourceFile is a full source path. Do not look it up in the SourceDisksNames section of the INF file.
    SP_COPY_SOURCEPATH_ABSOLUTE
    SourcePathRoot is the full path part of the source file. Ignore the relative source specified in the SourceDisksNames section of the INF file for the source media where the file is located. This flag is ignored if SP_COPY_SOURCE_ABSOLUTE is specified.
    SP_COPY_FORCE_IN_USE
    If the target exists, behave as if it is in use and queue the file for copying on the next system reboot.
    SP_COPY_FORCE_NOOVERWRITE
    Check whether the target file exists, and, if so, the file is not overwritten. The caller is not notified.
    SP_COPY_FORCE_NEWER
    Examine each file being copied to see if its version resources (or time stamps for non-image files) indicate that it is not newer than an existing copy on the target. If the file being copied is not newer, the file is not copied. The caller is not notified. The function returns FALSE, and GetLastError returns NO_ERROR.
    CopyMsgHandler
    Optional pointer to a callback function to be notified of various conditions that may arise during the file copy.
    Context
    Optional pointer to a caller-defined value that is passed as the first parameter of the callback function.
    Return Values
    If the function succeeds, the return value is a nonzero value.

    If the function fails, the return value is zero. To get extended error information, call GetLastError.

    If GetLastError returns NO_ERROR, the file copy operation was not completed. The file may not have been copied because the file copy operation was unnecessary or because the file callback function returned FALSE.

    Remarks
    If a UNC directory is specified as the target directory of a file installation, you must ensure it exists before you call SetupInstallFile. The setup functions do not check for the existence of and do not create UNC directories. If the target UNC directory does not exist, the file installation will fail.

    Requirements
    Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0, Windows Me, Windows 98, and Windows 95.
    Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server 4.0.
    Unicode: Implemented as Unicode and ANSI versions, except on Windows Me/98/95.
    Header: Declared in Setupapi.h.
    Library: Use Setupapi.lib.


    Wywołuję ją w postaci:
    Cytat:

    void __fastcall TForm1::FormCreate(TObject *Sender)
    {
    SetupInstallFile(NULL,NULL,"ftdibus.inf",NULL,"ftdibusbus.inf",SP_COPY_SOURCE_ABSOLUTE,NULL,NULL);
    SetupInstallFile(NULL,NULL,"ftdiport.inf",NULL,"ftdibusport.inf",SP_COPY_SOURCE_ABSOLUTE,NULL,NULL);
    }


    Lecz wciąż sterowniki nie sa instalowane. Napewno są one dobre. Jeśli automatycznie wyszukuję sterowników to są one instalowane, ale chodzi o instalację z poziomu c++. Wiem, ze użyłem złych parametrów przy wywołaniu funkcji. Mógłby mi ktoś pomóc? nie do końca rozumiem objaśnienia tejże funkcji. Nie ma wersji polskiej.

    Dodano po 35 [minuty]:

    ZNajduje się ona oczywiście w setupapi.h