Read Installed Device Driver Details (version, install date, path etc), on Win system - api

Can anyone help please in this regard ?
What API's can be used from win32 to get installed device drivers details like
version, installation date, path where installed ?
Regards,
Kedar

The best way is WMI, .NET supports it well with the System.Management namespace. You'll want to use the Win32_SystemDriver WMI class. I copied and pasted this code from WMICodeCreator, a great tool to experiment and auto-generate the code you need:
using System;
using System.Management; // Project + Add Reference required
public class MyWMIQuery {
public static void Main() {
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_SystemDriver");
foreach (ManagementObject queryObj in searcher.Get()) {
Console.WriteLine("Driver caption: {0}", queryObj["Caption"]);
}
Console.ReadLine();
}
}
Check out the links I left in this post, Win32_SystemDriver has many other properties beyond "Caption".

You need to consult the Setup API function for driver information.

I recently did something similar (Win32 via .NET). Here are some links that helped me:
http://www.codeproject.com/KB/system/SimpleSetup.aspx
http://www.pinvoke.net/default.aspx/setupapi/SetupDiGetDeviceRegistryProperty.html
http://www.codeguru.com/forum/showthread.php?t=360567

Related

RDLC with .NET Core 5.0 throws error in production if I use expressions inside report creation, works fine in development

I'm using RDLC to create reports with my .NET Core Web API. I spent an entire week creating 3 reports using lots of expressions. Now after publishing the application on IIS every report fails with error
An error occurred during local report processing.;An unexpected error
occurred in Report Processing.Object reference not set to an instance
of an object
The report works fine in development. After lots of research I found the issue is with expressions. I have been struggling to find a solution for almost a day searching the entire web. Many people suggested that this is the limitation of RDLC and we can't use expressions. Without expressions there is no use of this tool for me. I can't afford to spend another week to re-create those reports using another tool. In fact I don't even know what else can I use instead of RDLC to create reports.
Any suggestion to fix these issues or an alternative to RDLC will be life saving for me....
It's been a pain to use this unstable tool, but unfortunately I'm stuck in this.
Thanks
Having .NET Core work with library from .NET framework is painful to say the least.
Thanks for the recompiled WinForms library provided by lkosson.
I managed to make this work but it looks like bandage fix more then anything.
Very Important Note!! This solution make use of WPF, WinForms version of RDLC. This limit the .NET 5 solution to Windows build only. (I can't make Web version to work, maybe someone else can)
1. Update .NET 5 project settings
Unload the .NET 5 project
Right click and Edit .csproj
Update/Add 3 lines in property group as following:
<PropertyGroup>
--><TargetFramework>net5.0-windows</TargetFramework>
<RootNamespace>Net_Core_5._0</RootNamespace>
--><UseWindowsForms>true</UseWindowsForms>
--><EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
</PropertyGroup>
Reload the project
2. Add NuGet Packages
Add and install the following packages:
Microsoft.ReportViewer.Common
Microsoft.ReportViewer.WinForms
ReportViewerCore.WinForms
3. Use .NET version's function to generate Report
This is an example for your reference,
using Microsoft.Reporting.WinForms;
using System;
using System.Collections.Generic;
using System.Data;
namespace NET_4._8_RDLC_Lib
{
public class ReportGenerator
{
/// <summary>
/// .NET Core use this function to render reports
/// </summary>
public static byte[] RenderReport(String reportPath, Dictionary<string, DataTable> data, string format)
{
Microsoft.Reporting.WinForms.ReportViewer v1 = new Microsoft.Reporting.WinForms.ReportViewer();
v1.LocalReport.DataSources.Clear();
//Add all datasource to the Report
foreach (KeyValuePair<string, DataTable> pair in data)
{
Microsoft.Reporting.WinForms.ReportDataSource ds = new ReportDataSource(pair.Key, pair.Value);
v1.LocalReport.DataSources.Add(ds);
}
v1.LocalReport.EnableExternalImages = true;
v1.LocalReport.ReportPath = reportPath;
return v1.LocalReport.Render(format: format, deviceInfo: "");
}
}
}
The file is just inside the bytes array.

'WebHost' does not contain a definition for 'CreateDefaultBuilder'

I work on the migration of an .NET CORE API.
Firstly, I have this error message :
The name 'WebHost' does not exist in the current context
So Visual Studio suggest me to have this namespace :
using Microsoft.AspNetCore.Hosting.Internal;
I put it in my file, after that I have this error message :
'WebHost' does not contain a definition for 'CreateDefaultBuilder'
I don't know why it's doing that. Can I have some help ?
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args);
You need a reference to Microsoft.AspNetCore and include the namespace using Microsoft.AspNetCore;. If you use a template, they usually include a meta-package. Depending on the version (2.0 or 2.1) and your IDE, it either will be Microsoft.AspNetCore.All or Microsoft.AspNetCore.App. There you will have all necessary packages included. Is convenient but you might want to add what you need manually.
The suggestion to Microsoft.AspNetCore.Hosting.Internal is not what you are looking for. What you are looking for you find here.

QuickBooks API throws exception com.intuit.apache.http.HttpRequest

I am using the QuickBooks Javav3SDK2.0.3 in a java web project and trying to get list of customers as given below, however I am getting the below exception. The API expects request of type com.intuit.apache.http.HttpRequest while it is passed the HttpServletRequest.
Code:
OAuthAuthorizer oauth = new OAuthAuthorizer(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
Context context = new Context(oauth, APP_TOKEN, ServiceType.QBO, COMPANY_ID);
DataService service = new DataService(context);
Customer customer = new Customer();
List<Customer> customers = service.findAll(customer);
Iterator itr = customers.iterator();
while (itr.hasNext())
{
Customer customer2 = (Customer) itr.next();
String customerName = customer2.getFullyQualifiedName();
System.out.println(customerName);
}
Exception:
java.lang.IllegalArgumentException: This consumer expects requests of type com.intuit.apache.http.HttpRequest
I ran your code using the Javav3SDK2.0.3 and it worked fine for me. Are you sure every object you're using is from the same SDK? (2.0.3). My guess is whatever calls the authorize method on OAuthAuthorizer behind the scenes is passing in the HTTPServeletRequest instead of the com.intuit.apache.http.HttpRequest due to some sort of sdk version mismatch. I couldn't find any docs on the older quickbooks java sdk so I could be wrong.
I got it resolved by installing MyEclipse 11 (Version: 2013 SR1) on another system (CentOS) while the previous system was Linux Fedora. Although I am still using jboss 7, however it works now. I don't know exactly how it got working, so no clue is available.
This is due to the .jar you are using. If you check the QuickBooks SDK, you might be able to see that there are some jars with the name followed by "with dependencies".
For example ipp-v3-java-devkit-2.3.2-jar-with-dependencies.jar. If both this and the jar with out dependencies (in this case ipp-v3-java-devkit-2.3.2.jar) are present at the same time, you might get the above error.
Remove the latter from the class path and you should be good to go.

Android calendar that pulls data from a server - is there any api's or plgins for

Android calendar that pulls data from a server - is there any api's or SDK that would help with this.
Basically i have a site and want to add events to the calender in my app.. I haven't got the calender setup but will do..
I would like to dynamically pull data from my website or server..
Does anyone know of any resource or utorials on this that could help me in my quest for solving this..
any help appreciated..
I currently use libGDX framework for my apps if this help at all.
Best
You would need a way to access the database in your server, for example using PHP and MySql:
http://php.net/manual/en/book.mysqli.php
Then from libgdx a HttpRequest would work. Its the basics at least.
HttpRequest request = new HttpRequest(HttpMethods.GET);
request.setUrl("http://domainname.com/path/phpfile.php?argument=value");
Gdx.net.sendHttpRequest(request, new HttpResponseListener(){
#Override
public void handleHttpResponse(HttpResponse httpResponse){
Gdx.app.log("HttpRequestExample", "response: " + httpResponse.getResultAsString());
}
#Override
public void failed(Throwable t){
Gdx.app.error("HttpRequestExample", "something went wrong", t);
}
});

Wix install with multiple services, and I don't how many

I need to install my windows service, and have at least one instance of it. The user decides how many services they will have. But which approach will I take?
Try to make my ServiceInstall foreach the number of windows services or install them with an customization via installutil?
and then I have to solve so it does not install duplicates. But I can make an xml file that contains the service names to be installed, and read from there.
But I have read that people don't like using foreach in wix because it complicates stuff much more, and some people say installutil isn't good either. But since I don't know how many services it will be I have to solve it something like this.
And with installutil i won't get rollback either?
Does anyone know another approach?
You can run custom action which patches your MSI including service elements to install. This approach allows you to read service names from wherever you want and install as many services as you need.
Though it would be quite non-trivial for those who read your installer source code later. And to be honest I've never used this approach. But it should work...
I ended up doing this
public static void Main(string[] args)
{
if (System.Environment.UserInteractive)
{
string parameter = string.Concat(args);
switch (parameter)
{
case "install":
ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location });
break;
case "uninstall":
ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location });
break;
}
}
else
{
ServiceBase.Run(new WindowsService());
}
}
}
making my service installable and uninstallable on its own and then made customactions to install and uninstall them