Install driver using InstallShield(USB device) - usb

1) I am trying to register the Dll in Installshield based on the Hardware Info(USB\VID_12C1).
-> I want to know the device ID of the USB device connected to PC.
Then I want to fetch the USB device info into separate file.
-> From installshield I will pass the USB vendor ID to text file
and fetch the USB info.
-> Whether it is possible to do it in Installshield.
The following is the way I am trying to get the device ID:
szProgram = WINDIR ^ "temp" ^ "New" ^ "devcon.exe";
szCmdLine = " hwids *";
nvResult = LaunchAppAndWait(szProgram, szCmdLine, LAAW_OPTION_WAIT);
if (nvResult = 0) then
MessageBox ("ERROR: application created sucfuly", INFORMATION);
else
MessageBox ("ERROR: application", INFORMATION);
endif;
-> While installing the Installer trying to execute "devcon.exe hwids *"
through LaunchAppandwait Api. It will list the number of devices connected
to my PC. I want to save the device list in text file.
ISSUE: -> Unable to store the result in text file.
Please provide some ideas to store the device list into file and fetch
the required device list.

As far as I understand correctly you would like to know if certain device available on the system. For this purpose I would suggest to have a look on DevCon Find command, instead of getting entire list of devices. For example:
devcon find *USB\VID_046D*
If you insist to get the entire list of devices, and want to get it into the file you may look at this answer: Capturing stdOutput and stdError from LaunchApplication. Basically the simplest way is reditecting output into file. For example:
szProgram = WINDIR ^ "temp" ^ "New" ^ "devcon.exe";
szCmdLine = " hwids * > c:\temp\New\hardware.txt";
And in order to parse the file content you would need to get the file content. You may use GetLine or ListReadFromFile functions. The following would be example: OpenFile Example

Related

OPEN_PIPE_NO_AUTHORITY upon opening non-existing file using OPEN DATASET FOR OUTPUT IN BINARY MODE without FILTER

I have a very strange problem.
I have a standard program with the following piece of code that tries to create a file in response to a previous attempt to open it with OPEN DATASET ... FOR INPUT IN BINARY MODE.
CATCH SYSTEM-EXCEPTIONS dataset_too_many_files = 6
open_dataset_no_authority = 7
open_pipe_no_authority = 8
dataset_no_pipe = 9.
OPEN DATASET filename FOR OUTPUT IN BINARY MODE
MESSAGE msg.
ENDCATCH.
Suprisingly the response to that is sy-subrc = 8 which according to SAP documentation can happen only when OPEN DATASET is used with FILTER.
The message in msg variable has that File could not be opened, which is irrelevant because we are trying to create this file.
Did anybody experienced something like that? I suppose it has something to do with authority to create a file in a given directory on the operating system level but I cannot find any other log or trace to that. The error message and sy-subrc = 8 seem to be actually misleading in this case. Could more pieces of information be seen by activated tracing in ST01?
It turned out that the cause of the problem was in the first place the lack of the directory in which the file should be created. No wonder the system could not create the file in a non-existing folder. The error message is in such a case a misleading one anyway.
Open Dataset Docu:
and
Open datset os additions
Suprisingly the response to that is sy-subrc = 8 which according to SAP documentation can happen only when OPEN DATASET is used with FILTER.
Not exactly what the docu says. Worth another look.
Ie Would add sy-subrc = 8 on the open dataset command means
The operating system could not open the file.

Qlik Sense: how to specify path in Google Drive?

I have a Google drive account divided into some folders (say, Folder1, Folder2, etc.), with some subfolders in it.
I successfully managed to connect my Qlik Sense app to it.
I need to make it look for files only in a given subfolder.
At the moment, I read as follows ([...] is the location)
(URL IS [[...]connectorID=GoogleDriveConnector&table=ListSpreadsheets&appID=], qvx);
It works and reloads successfully, but I need it to filter the Spreadsheets properly. How could I get what I need?
To connect to Google Drive in fact you use web connector. Once web connector is installed it can be initialized as service or manually from its folder.
Once it i installed (recent version can be downloaded from https://qliksupport.force.com/apex/QS_Home_Page but it seems that you've got it as Google Drive is part of it ) it is much nicer to configure connection to online drives there.
You just go to http://localhost:5555/web and generate ready code.
In my implementation I used following options step by step to get data which I wanted:
1) CanAuthenticate to generate permanent token
2) ListSpreadsheets
3) ListWorksheets
4) GetWorksheet
You can't just specify path. But it's possible to retrieve the path from QWC services. Please use algorithm like that:
Use tables like ListFiles/ListWorksheets
Iter through every row with 'for' cycle:
FOR i=0 to (NoOfRows('Google_ListWorksheets')-1);
Let vWorksheetKey = Peek('worksheetKey', $(i), 'Google_ListWorksheets');
Let vTitle = left(Peek('title', $(i), 'Google_ListWorksheets'),3);
Using 'if' statement find desired folder id/worksheet key by its name (stored in vTitle variable) and use it:
load * FROM [$(vQwcConnectionName)]
(URL IS [http://localhost:5555/data?connectorID=GoogleDriveConnector&table=GetWorksheet&worksheetKey=$(vWorksheetKey)&appID=], qvx);
At the end you will get your files by their location.

Automatic download of created file in Sencha Touch 2

My Sencha Touch 2 application has an 'Export' button, which creates an Excel file with the data of the selected offer.
After the user clicks the button, i want the (server side) export process to be started, and, once completed, the user to be prompted to select a filename and location, OR that the file is automatically downloaded. How do i do that? Does anyone have an example?
For Excel specifically I'm not 100% sure, but this might help you get started or if a CSV is acceptable...
I'm sure you could pass the file reference to a var instead of the string but I have yet to try it.
If you paste the js below into the console you can see how this works. Pretty basic. Maybe try the returned value from the server to see if that works then if it does you can build a function around it to happen when needed.
csvHeading = 'HA, HB, HC, HD \n';
csvData = 'r3a, r3b, r3c, r3d \n' +
'r2a, r2b, r2c, r2d';
CSVFile = csvHeading + csvData;
window.location = 'data:text/csv;charset=utf8,' + encodeURIComponent(CSVFile);

Get USB disk drive letter by device path or handle

My goal is to write a c-dll (compiled with MinGW) that is able to search for certain models of USB sticks connected to the computer and deliver the serial number, the vendor ID, the product ID and the drive letter.
I have searched on the internet for several hours know but could not find an approach that works for me.
I am using the Setup Api to get a list of all connected USB devices. For each USB device I get a path that looks like this:
\?\usb#vid_048d&pid_1172#00000020370220#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
From that string I can get the vendor ID, product ID and the serial number I am looking for.
My problem is now to determine the drive letter of the USB drive that is related to this device path.
During my internet research I found the following approach multiple times (for example here http://oroboro.com/usb-serial-number/):
Once the device path is found, the USB drive must be opened by CreateFile. The handle returned by that function can be used to get the device number by function DeviceIOControl with IOCTL_STORAGE_GET_DEVICE_NUMBER.
After that, the CreateFile function could be used to open each drive letter (starting from a:) and try to get the device number the same way like described above. Once the same device number is found again, the relation between device path and drive letter is made.
My Problem is that the IOCTL_STORAGE_GET_DEVICE_NUMBER call is not working. The DeviceIOControl function returns error code 50 which means "The request is not supported".
I am not able to create a link between the device path of a USB stick and the drive letter. I have tried several IOCTL_STORAGE and IOCTL_VOLUME calls but none worked for the USB sticks I tried.
I also read in another Forum that people had problems with the results of the DeviceIOControl function. It was returning the desired result on some PCs while it was making trouble on others.
Is there another way of achieving my goal?
I already had a look into the registry where I can also find the desired data. But again I had the problem to create the connection between device path and drive letter.
I would not like to use the WMI. I have read that it is still not really supported by MinGW.
I have a implementaion for all this with C# where it is really easy to get the desired information, but now I also need one that is created with unmanaged code and can be used to replace a c-dll also included in Delphi projects.
I would appreciate any suggestions for a solution to my problem.
Best regards,
Florian
And here the code if someone is interested. The position with this comment "//HERE IS WHERE I WOULD LIKE TO GET THE DEVICE NUMBER!!!" is where the request of the device number would be used if it would work.
typedef struct ty_TUSB_Device
{
PSP_DEVICE_INTERFACE_DETAIL_DATA deviceDetailData;
char devicePath[300];
}TUSB_Device;
int
GetUSBDevices (TUSB_Device *devList[], int size)
{
HANDLE hHCDev;
HDEVINFO deviceInfo;
SP_DEVICE_INTERFACE_DATA deviceInfoData;
ULONG index;
ULONG requiredLength;
int devCount = 0;
//SP_DEVINFO_DATA DevInfoData;
// Now iterate over host controllers using the new GUID based interface
//
deviceInfo = SetupDiGetClassDevs((LPGUID)&GUID_DEVINTERFACE_USB_DEVICE,
NULL,
NULL,
(DIGCF_PRESENT | DIGCF_DEVICEINTERFACE));
if (deviceInfo != INVALID_HANDLE_VALUE)
{
deviceInfoData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
for (index=0;
SetupDiEnumDeviceInterfaces(deviceInfo,
0,
(LPGUID)&GUID_DEVINTERFACE_USB_DEVICE,
index,
&deviceInfoData);
index++)
{
SetupDiGetDeviceInterfaceDetail(deviceInfo,
&deviceInfoData,
NULL,
0,
&requiredLength,
NULL);
//allocate memory for pointer to TUSB_Device structure
devList[devCount] = malloc(sizeof(TUSB_Device));
devList[devCount]->deviceDetailData = GlobalAlloc(GPTR, requiredLength);
devList[devCount]->deviceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
SetupDiGetDeviceInterfaceDetail(deviceInfo,
&deviceInfoData,
devList[devCount]->deviceDetailData,
requiredLength,
&requiredLength,
NULL);
//open the usb device
hHCDev = CreateFile(devList[devCount]->deviceDetailData->DevicePath,
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
// If the handle is valid, then we've successfully found a usb device
//
if (hHCDev != INVALID_HANDLE_VALUE)
{
strncpy(devList[devCount]->devicePath, devList[devCount]->deviceDetailData->DevicePath, sizeof(devList[devCount]->devicePath));
//HERE IS WHERE I WOULD LIKE TO GET THE DEVICE NUMBER!!!
CloseHandle(hHCDev);
devCount++;
}
//GlobalFree(devList[devCount]->deviceDetailData);
}
SetupDiDestroyDeviceInfoList(deviceInfo);
}
return devCount;
}
I found out what my problem was. From what I read on the internet it seems there where other people having the same problems like me, so I will post my solution.
The whole point is that there are obviously different path values one can obtain for a USB device using the SetupApi. All path values can be used to get a handle to that device, but there are obviously differences about what can be done with the handle.
My failure was to use GUID_DEVINTERFACE_USB_DEVICE to list the devices. I found out that when I use GUID_DEVINTERFACE_DISK, I get a different path value that lets me request the device number. That way I am able to get the link to the drive letter.
That path value obtained with GUID_DEVINTERFACE_DISK also contains the serial number but not the vendor and product IDs. But since both path values do contain the serial, it is no problem to get them both and build the relation.
I tested the code with Windows XP, 7 and 8 and it works fine. Only the FileCreate code of the code sample above must be adjusted (replace GENERIC_WRITE by 0). Otherwise Administrator rights or compatibility mode are required.
I did not try to find out what these different GUID values really stand for. Someone with a deeper knowledge in this area could probably provide a better explanation.
Best regards,
Florian

How to tell if a given path is mounted removable media in Mac OS X?

Given a path, in Mac OS X, is there a way to tell that it is a mounted CD or DVD, as opposed to a regular directory, a regular file, or mounted DMG or other mountable file type? Specifically I would like to know if it is a CD or DVD when a user supplies a path directly, or via the NSOpenPanel, or drags the CD onto the app. I need to take special action in these cases.
Check out Apple's VolumeToBSDNode example code. I believe it should have the code bits you need.
Description
Shows how to iterate across all mounted volumes and retrieve the BSD node name (/dev/disk*) for each volume. That information is used to determine if the volume is on a CD, DVD, or some other storage media.
As Kent points out, the PBHGetVolParmsSync call in this example is deprecated. Here's a diff to use the newer function:
- HParamBlockRec pb;
- // Use the volume reference number to retrieve the volume parameters. See the documentation
- // on PBHGetVolParmsSync for other possible ways to specify a volume.
- pb.ioParam.ioNamePtr = NULL;
- pb.ioParam.ioVRefNum = actualVolume;
- pb.ioParam.ioBuffer = (Ptr) &volumeParms;
- pb.ioParam.ioReqCount = sizeof(volumeParms);
-
- // A version 4 GetVolParmsInfoBuffer contains the BSD node name in the vMDeviceID field.
- // It is actually a char * value. This is mentioned in the header CoreServices/CarbonCore/Files.h.
- result = PBHGetVolParmsSync(&pb);
+ // Use FSGetVolumeParms instead of the deprecated PBHGetVolParmsSync
+ result = FSGetVolumeParms(actualVolume, &volumeParms, sizeof(volumeParms));
+