如何在注册表中注册设备并使用c#windows应用程序获取注册的设备信息? [英] how to register a device in registry and get registered device info using c# windows application?

查看:88
本文介绍了如何在注册表中注册设备并使用c#windows应用程序获取注册的设备信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





目前我正在使用OPOS设备应用程序。我必须创建一个应用程序,它将安装必要的驱动程序并在注册表中添加设备信息。我想知道如何在给定目录下的注册表中注册设备。

假设我想按照以下规范注册MSR(磁性脚本阅读器)注册表。



[HKEY_LOCAL_MACHINE\SOFTWARE\OLEforRetail\ServiceOPOS \ MSR \ MSR210D]

@ =OPOS.MSR.213USO.1

描述=统一的MSR213U OPOS服务对象。(213OPS)

MSRKeyboardHookFlag= dword:00000001

MSRType=ISO 1/2 / 3 + JIS

服务=MSR213USO.dll

版本=1.12.1

WaitTime= dword:00000064



[HKEY_LOCAL_MACHINE\SOFTWARE\OLEforRetail\ServiceOPOS \ MSR \ MSR213U]

@ =OPOS。 MSR.213USO.1

WaitTime= dword:00000064

D escription=统一MSR213U OPOS服务对象。 (213OPS)

服务=MSR213USO.dll

版本=1.12.1

MSRType= ISO 1/2/3 + JIS

MSRKeyboardHookFlag= dword:00000001



我将如何做,请帮助我。





提前致谢。

Hi,

Currently i am working OPOS device application.Here i have to create a single application that will install the necessary driver and add device information in the registry .I wanted to know how to register device in the registry under given directory.
Suppose i want to register MSR(magnetic Script Reader) to registry with following specification.

[HKEY_LOCAL_MACHINE\SOFTWARE\OLEforRetail\ServiceOPOS\MSR\MSR210D]
@="OPOS.MSR.213USO.1"
"Description"="Uniform MSR213U OPOS Service Object. (213OPS)"
"MSRKeyboardHookFlag"=dword:00000001
"MSRType"="ISO 1/2/3 + JIS"
"Service"="MSR213USO.dll"
"Version"="1.12.1"
"WaitTime"=dword:00000064

[HKEY_LOCAL_MACHINE\SOFTWARE\OLEforRetail\ServiceOPOS\MSR\MSR213U]
@="OPOS.MSR.213USO.1"
"WaitTime"=dword:00000064
"Description"="Uniform MSR213U OPOS Service Object. (213OPS)"
"Service"="MSR213USO.dll"
"Version"="1.12.1"
"MSRType"="ISO 1/2/3 + JIS"
"MSRKeyboardHookFlag"=dword:00000001

How will i do it ,Please help me.


Thanks in advance.

推荐答案

请不要更改OPOS Linedisplay的配置设置。

在您托管opos控件的usercontrol中使用以下代码,并检查您的设备是否正在运行。



Please do not change the configuration settings for OPOS Linedisplay.
Use the following code in your usercontrol where you have hosted your opos control and check that your device is running or not.

<pre>
 ret =  OPOSLineDisplay.Open("FTLDSO");
 ret =  OPOSLineDisplay.ClaimDevice(100);
    OPOSLineDisplay.DeviceEnabled = true;
        OPOSLineDisplay.CharacterSet = 3;
        OPOSLineDisplay.ClearText();
        OPOSLineDisplay.DisplayTextAt(0, 0, &quot;Line Display Test&quot;, 0);
    OPOSLineDisplay.DisplayTextAt(1, 0, &quot;Line Display Working&quot;, 0);
    OPOSLineDisplay.ReleaseDevice();
        OPOSLineDisplay.Close();



如果您发现任何错误请告诉我,如果符合您的要求,请将其标记为答案。


Do let me know if you find any error and please mark it as answer if it is valid answer to your requirements.


对于32位应用程序将OPOSMSR.ocx复制到

> C:\ Windows \ System32

>在cmd中运行以下内容

- > regsvr32 /sc:\windows\System32 \OPOSMSR.ocx

----------- -------------------------------------------------- ------------------

对于64位应用程序将OPOSMSR.ocx复制到

> C:\ Windows \ SysWOW64

>在cmd中运行以下内容

- > regsvr32 /sc:\windows\SysWOW64 \ OPOSMSR.ocx



一旦这是完成

在Windows应用程序中添加一个新的用户控件。转到设计器页面并打开工具箱窗口。

在工具箱窗口中 - >右键单击并选择选择项目 - >选择Com Components选项卡,找到已注册的OPOS MSR控件。选择它并单击OK。

将此OPOS MSR控件放在用户控件上。您的控件是托管的,您可以使用它。

要浏览此组件中的所有方法,请转到后面的代码,导航到'InitializeComponent'方法。在最后一行,您将找到托管控件的实例。去定义'AxOPOSMSR'你会找到所有的方法。



---------------------- -------------------------------------------------- -----

要查找OPOSMSR控件的名称,您可以从运行命令导航regedit.exe和

Local_Machine - >软件 - > OLE For Retail您可以找到您的MSR控件。
For 32 bit application Copy OPOSMSR.ocx to
> C:\Windows\System32
> Run the following in cmd
->regsvr32 /s c:\windows\System32\OPOSMSR.ocx
-------------------------------------------------------------------------------
For 64 bit application Copy OPOSMSR.ocx to
> C:\Windows\SysWOW64
> Run the following in cmd
->regsvr32 /s c:\windows\SysWOW64\OPOSMSR.ocx

Once this is done
Add a new user control in your windows application. Go to designer page and open Toolbox window.
In the toolbox window -> right click and Select 'Choose Items' -> Select Com Components tab and find OPOS MSR control registered.Select it and click on OK.
Put this OPOS MSR control on your User control. Your control is hosted and you can use it.
To explore all the methods in this components, go to code behind, Navigate to 'InitializeComponent' method. At the last line you will find instance of your hosted control. Go to Defination 'AxOPOSMSR' you will find all methods.

-----------------------------------------------------------------------------
To find the name your OPOSMSR control you can navigate regedit.exe from run command and
Local_Machine ->Software -> OLE For Retail you may find your MSR control.


这篇关于如何在注册表中注册设备并使用c#windows应用程序获取注册的设备信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆