How to find the latest virtual COM port created in my Pc??
device manager -> ports -> devicename ( COM X ).
How to find that "COM x" programatically?
Look at the SetupApi, specifically the SetupDiEnumDeviceInfo() and CM_Get_Device_ID() functions.
This project has some sample code that shows the usage.
"Install Date" is one of the properties on the details tab of a hardware properties page from device manager.
I expected to be able to find a key in the registry for it:
HKLM\SSYSTEM\CurrentControlSet\Enum\...
But there isn't a key, or at least, I can't find one.
Will a search by VendorID + DeviceID/ProductID be sufficient?
Related
I need to automate a manipulation through powershell, but I just don't know how to do so.
Here is the manual procedure:
Click on "Component Services":
Click on "Property" of the computer
Click on "Property" of the "TCP/IP connexion"
Add a port range
Enter a port range, then hit "OK"
I searched for quite a while online, and got some clues on how to do access the related WMI Object, but from there, I am stuck. I used trial and error to no avail.
If anyone has ever done this, or know more about it, I would be glad to know it.
Registry Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\Internet
ValueName: Ports
Type: REG_MULTI_SZ
Example export of the key from Regedit.exe, from Windows Server 2016, for ports: 60001-61248:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Rpc\Internet]
"PortsInternetAvailable"="N"
"UseInternetPorts"="N"
"Ports"=hex(7):36,00,30,00,30,00,30,00,31,00,2d,00,36,00,31,00,32,00,34,00,38,\
00,00,00,00,00,00,00
A link describing these settings in more detail is:
How to configure RPC dynamic port allocation to work with firewalls
I originally found a hint to this registry key on this web page: Troubleshooting RPC Endpoint Mapper errors using the Windows Server 2003 Support Tools from the product CD
Microsoft WDK's Toaster sample code contains a ClassInstaller example(tostrcls.dll). It shows the ability to customize "device friendly name" displayed by Device Manager. The ability is achieved by modifying FriendlyName's value for the device's hardware key . After modifying FriendlyName, a close and reopen of the Device Manager window(devmgmt.msc) will reflect such changes. So far, so good.
However, in order to tell Device Manager window to reflect the change immediately(without close and reopen its window), some extra code has to be run. classInst.c takes the following way:
spDevInstall.FlagsEx |= DI_FLAGSEX_PROPCHANGE_PENDING;
SetupDiSetDeviceInstallParams(Params->DeviceInfoSet,
Params->DeviceInfoData,
&spDevInstall);
That works, but NOT optimal. DI_FLAGSEX_PROPCHANGE_PENDING causes the device to go through a STOP/START cycle. I mean, the driver's ToasterEvtDeviceReleaseHardware and ToasterEvtDevicePrepareHardware get executed. I think this is an undesired side-effect.
So my question is clear. Is there a way to refresh Device Manager's display without bothering with the driver code?
I got the answer from WDK7 PnpPorts project(which is the ClassInstaller that implement the Windows COM Port "Port Setting" tab).
Just change
spDevInstall.FlagsEx |= DI_FLAGSEX_PROPCHANGE_PENDING;
to
spDevInstall.Flags |= DI_PROPERTIES_CHANGE;
all done.
Note: The device-restarting behavior of DI_FLAGSEX_PROPCHANGE_PENDING is documented in WDK7 chm page "DIF_ADDPROPERTYPAGE_ADVANCED" but not in "SP_DEVINSTALL_PARAMS". I only check the latter, so missed it.
I downloaded the example for a port monitor including localmon (http://tinyurl.com/kg8bvt7).
It compiles in VS2013. I managed to add a driver package to the solution. And I setup a test PC using WDK 8.1 (wdktestsetup.exe). I can ping this test PC from my development PC.
However, if I go to the Properties page of my driver package and choose "Deployment" I enabled deployment (check mark), specified the target computer name by it's IP address, choose "Install and verify" and from the combobox I selected "Default Printer Driver Package Installation Task (possible reboot)", then I still get an error when I try to deploy.
I build for "Win7 Debug" configuration and "Win32" platform.
The error which I get is:
Error 1 error : Could not connect to the remote computer for deployment. C:\Program Files (x86)\Windows Kits\8.1\build\Win32\ImportAfter\DriverDeployment.targets 69 9 monitors
Error 2 error : Printer model name must be supplied for printer driver deployment. The model name must be supplied on the DriverInstall->Deployment property page. C:\Program Files (x86)\Windows Kits\8.1\build\Win32\ImportAfter\DriverDeployment.targets 69 9 monitors
I searched on info for the second error ... and I found this help:
http://msdn.microsoft.com/es-es/library/dn641620%28v=vs.85%29.aspx
In section "Configure driver solution for debugging and deployment" it states that you should be able to "Type the name of the driver in the Optional Arguments field". I do not see such an Optional Arguments field in my VS2013 ...
Any hints on what I could try?
Thanks.
In the deployment property page, under the "Install and Verify" option, there is a text box where you can add text. That's where you should supply the printer model name.
If you can't see that text box, you might want to resize the property page to increase its height. I seem to remember that there was an issue in WDK 8 where there would be no vertical scroll bar on that property page, even though there should be. I'm not 100% sure if it was fixed in WDK 8.1.
I'm attempting to access a physical device using a software package from the vendor.
In earlier versions of the software package they had the user open the device via the DOS Symbolic name:
hDevice= CreateFile("\\\\.\\DevName",
GENERIC_READ | GENERIC_WRITE,
0, NULL, OPEN_ExiSTING, 0, NULL);
However, they released a new version which requires the device be opened by GUID and a DEFINE_GUID is included in their header. This update also disabled the old method to open the device.
They did not update their documentation to show how to open the device by GUID and I haven't been able to find anything helpful with my google-fu.
Surely there must be an example somewhere showing how to open a device using the GUID?
Most likely the vendor gave you a 'device interface GUID'.
To get a name that you can use for CreateFile(), you have to enumerate all devices with that GUID. This is done by calling SetupDiGetClassDevs() with the flag DIGCF_DEVICEINTERFACE. The resulting list is represented by a handle to a device information set (a HDEVINFO). Then you feed that handle into repeated calls to SetupDiEnumDeviceInterfaces() to walk the list. For each list item you then have to call SetupDiGetDeviceInterfaceDetail() to receive the corresponding device path.
You've probably figured it out by now, but WinObj is pretty handy for poking around the object manager namespace. Once you find the name of the object you're looking for there, it should be pretty straightforward to get the open right.
I'd like to determine how to programatically start/stop/pause the indexer from Microsoft Search.
I know it is possible because I've seen it done in programs like this one: http://brandontools.com/files/folders/sidebar_gadgets/entry511.aspx
However, I cannot find any docs on MSDN or anywhere.
There is a "Windows Search" service which can be controlled with traditional service control methods. However, starting/stopping this service also changes the availability of search itself. I want to control just the indexer.
Does anyone know where docs may be found that describe how to interact with the indexer? My search skills have failed me.
There isn't a way to simply disable the indexing part. It's an all or nothing service. The description of the WSearch service states:
"Provides content indexing and property caching for file, email and other content (via extensibility APIs). The service responds to file and email notifications to index modified content. If the service is stopped or disabled, the Explorer will not be able to display virtual folder views of items, and search in the Explorer will fall back to item-by-item slow search."
However, you might be able to control it through drive/folder properties ... from Explorer, you can switch it of for an individual drive (see the properties of a drive; there's an option "allow indexing service..."), or for a folder (folder properties -> advanced -> "For fast searching, allow indexing service...").
EDIT ... a bit of googling, and the above properties are available - if you look at the MSDN page for System.IO.FileAttributes, there's a property NotContentIndexed with the description The file will not be indexed by the operating system's content indexing service. I would assume that you should be able to set this on individual folders. I don't know if this works if set at the drive level (without a recursive run through the drive), but hopefully it'll give you a head-start on whatever you're ultimately trying to achieve.
According the Microsoft there isn't an official way of doing so.
Here is a great tutorial on programmatically interacting with Windows Search: article at JoyOfCode.
The Windows Search 3.x SDK provides a .NET API that works against Windows Search 3 or 4.
Unfortunately, it doesn't expose pause/resume. All of the index control samples I have found use WMI to stop the search service. That will stop indexing, obviously, but at the expense of search itself not being available.
It's an old thread, but I ran across it. Someone else might as well.
Use an AutoIT script to open the Indexing Options and click the Pause button in the dialog box.
Something like this:
ServiceController service = new ServiceController("WSearch");
service.Start();
or
service.Stop();
Open the "Run" Dialog (Start | Run), type(or copy)
%SystemRoot%\system32\compmgmt.msc /s
and unfold the last one