# Read serial number by activeX

**URL:** <https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683>\
**Category:** Programming Questions\
**Tags:** activex, genicam\
**Created:** [April 25, 2022, 12:29pm UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683 "2022-04-25T12:29:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![bertrand](https://avatars.discourse-cdn.com/v4/letter/b/a88e4f/32.png) [@bertrand](https://forum.commonvisionblox.com/u/bertrand)\
**Post date:** [April 25, 2022, 12:29pm UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683/1 "2022-04-25T12:29:54Z")

</div>

Hello,

I work on Windev software.  
I add on the project Cvb activeX (Image control and Display)

On the Image control i can use “serial number”.  
I would like use it to check if the camera is online ( i have only 1 camera).  
I “initialize” the activeX, i can take a picture and save it, but the serial number command return 0 everytime and i don’t find why.  
On Cvb viewver i see the camera and the serial ID.

// initialize  
( AX\_CVB = image control activeX and AX\_Display is display activeX)

AX\_CVB\>\>LoadImage(“C:\Program Files (x86)\STEMMER IMAGING\Common Vision Blox\Drivers\GenICam.vin”)  
AX\_Display\>\>Image = AX\_CVB\>\>Image

// code to serial

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/ef6b77ca108e631f4139beb5b5f256a4bed41eaa.png)

Can you help me ?

Best regards

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [April 26, 2022, 6:37am UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683/2 "2022-04-26T06:37:32Z")

</div>

Hi @bertrand

is there a reason why you want to go with the ActiveX Control?

If not, you could have a look at the following example:  
%cvb%\Tutorial\Image Manager\[Cvb.Net](http://Cvb.Net)

You can also get the SerialNumber directly from the NodeMap.  
Here is an example on how to get the NodeMap of a camera and work with it:

```cs
// Load driver 
using (Device device = DeviceFactory.Open("GenICam.vin")) 
{ 
  // Load NodeMap for the device 
  var dev_node_map = device.NodeMaps["Device"];   

  using (var camModel = dev_node_map["DeviceModelName"] as StringNode) 
  { 
    Console.WriteLine("Loaded device: " + camModel.Value); 
  }  

  using (var camFirmWare = dev_node_map["DeviceFirmwareVersion"] as StringNode) 
  { 
    Console.WriteLine("Current Firmwareversion : " + camFirmWare.Value); 
  }   

  using (var exposureTime = dev_node_map["ExposureTime"] as FloatNode) 
  { 
    Console.WriteLine("Current exposure time : " + exposureTime.Value); 
    var exposureTimeOld = exposureTime.Value; 
    exposureTime.Value = 32; 
    Console.WriteLine("Small exposure time : " + exposureTime.Value); 
    exposureTime.Value = exposureTimeOld; 
    Console.WriteLine("Resetted to old exposure time : " + exposureTime.Value); 
  } 
}

```

Also, if you only have one camera on the machine, what is the reason for checking the serialnumber?  
Maybe there is a better way to achieve what you want once we fully understand what you are trying to do.

Cheers  
Chris

---

<div class="post-metadata">

**Author:** ![bertrand](https://avatars.discourse-cdn.com/v4/letter/b/a88e4f/32.png) [@bertrand](https://forum.commonvisionblox.com/u/bertrand)\
**Post date:** [April 26, 2022, 7:01am UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683/3 "2022-04-26T07:01:27Z")

</div>

Hello Chris,

Thank you to your message.

I would like to keep activeX to work everytime with the same method, because we use different software and someone can use only ActiveX.

I would like check if the camera is present with the serial number, maybe an other tool is better to do that.

I hope to be clear.

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [April 26, 2022, 8:56am UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683/4 "2022-04-26T08:56:58Z")

</div>

Hi @bertrand ,

if no camera is connected then loading the driver will fail, that would be the easiest way to check as this results in an exception that you could handle.

If a camera was already found and gets disconnected for some reason, the following code will notify you (and also once the device is back up and running):

```cs
var device = DeviceFactory.Open("GenICam.vin"); 
device.Notify[NotifyDictionary.DeviceDisconnected].Event += Disconnect; 
device.Notify[NotifyDictionary.DeviceReconnect].Event += Reconnect;  

private static void Disconnect(object sender, NotifyEventArgs e) 
{ 
Console.WriteLine("Device disconnected"); 
// do stuff 
}  

private static void Reconnect(object sender, NotifyEventArgs e) 
{ 
Console.WriteLine("Device reconnected"); 
// do stuff 
}

```

With this combination you would be independent of the actual camera (model or even specific camera).  
If you still want to check for a specific camera you can still go with the NodeMap and the DeviceID (I think should be the serialnumber) node.

Hope this helps

Cheers  
Chris

---

<div class="post-metadata">

**Author:** ![bertrand](https://avatars.discourse-cdn.com/v4/letter/b/a88e4f/32.png) [@bertrand](https://forum.commonvisionblox.com/u/bertrand)\
**Post date:** [April 26, 2022, 9:17am UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683/5 "2022-04-26T09:17:42Z")

</div>

Ok thank you.

But i cannot do that only with property of activeX right ?

I need a little code section to check the connection.

Now i need to find how to do that on Windev.

Thank you to your help @Chris !

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [April 26, 2022, 9:32am UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683/6 "2022-04-26T09:32:44Z")

</div>

Hi @bertrand,

if I look into the %cvb%\Tutorial\Image Manager\CSharp\CSDisplay tutrorial and add the following line in the constructor of the MainForm:

var test = axCVimage1.SerialNumber;

I get ‘999’ as a value. This is the SerialNumber for my developer dongle to license CVB:

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/d192b9cb43545daa2729c9166da688f87e4ec961.png)  
So I think be both wrongly assumed this to be the Camera Serial Number where in fact it is not.

So you are left with one of my hints from earlier (Catch exception, Connection Monitoring, NodeMap for SerialNumber of camera).

Cheers  
Chris

---

<div class="post-metadata">

**Author:** ![bertrand](https://avatars.discourse-cdn.com/v4/letter/b/a88e4f/32.png) [@bertrand](https://forum.commonvisionblox.com/u/bertrand)\
**Post date:** [April 26, 2022, 9:42am UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683/7 "2022-04-26T09:42:32Z")

</div>

Ok, good to know …

I find the ping function on Windev to find device.  
I continue to search how i can add you example in my project.

Thank you so much for your help @Chris

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/chris/32/1154_2.png) [@Chris](https://forum.commonvisionblox.com/u/Chris)\
**Post date:** [April 26, 2022, 9:52am UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683/8 "2022-04-26T09:52:02Z")

</div>

Hi @bertrand ,

I have never worked with windev, so, unfortunately I cant help you on how to get CVB running in there.  
What I found out so far is, that windev has its own programming language.  
If there is a possibility to write your own plugins/classes/scripts using C++, C# or Python then I can provide you the code for what you want to do.

How to add these to windev: No idea.

I sorry I cant help you with this but at least I found this:  
[https://help.windev.com/en-US/?2012008&name=typing\_code](https://help.windev.com/en-US/?2012008&name=typing_code)

Cheers  
Chris

---

<div class="post-metadata">

**Author:** ![bertrand](https://avatars.discourse-cdn.com/v4/letter/b/a88e4f/32.png) [@bertrand](https://forum.commonvisionblox.com/u/bertrand)\
**Post date:** [April 26, 2022, 10:05am UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683/9 "2022-04-26T10:05:17Z")

</div>

No problem,

Thank you @Chris

---

<div class="post-metadata">

**Author:** ![illusive](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/illusive/32/61_2.png) [@illusive](https://forum.commonvisionblox.com/u/illusive)\
**Post date:** [April 27, 2022, 9:08pm UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683/10 "2022-04-27T21:08:02Z")

</div>

Hi @bertrand

sorry this confused you, but the `SerialNumber` property of the `CVImage` control actually reports - as the two of you found out - the CVB serial number, not the camera’s serial number. It is also somewhat outdated: CVB today supports more than just one serial number, but the property will only ever report the “best” one (i. e. the one that has the best tool coverage).

As a general rule, our ActiveX controls are more or less approaching their end of life and today we add new functionality to the [CVB.Net](http://CVB.Net), CVBpy and CVB++ API rather than to the ActiveX controls, so not everything that you find here on the forum can be guaranteed to be feasible with the ActiveX controls (device discovery is one example that comes to mind, another one would be the more advanced acquisition features like MultiPart or FlowSetPools).

---

<div class="post-metadata">

**Author:** ![bertrand](https://avatars.discourse-cdn.com/v4/letter/b/a88e4f/32.png) [@bertrand](https://forum.commonvisionblox.com/u/bertrand)\
**Post date:** [April 28, 2022, 6:10am UTC](https://forum.commonvisionblox.com/t/read-serial-number-by-activex/1683/11 "2022-04-28T06:10:24Z")

</div>

Hi,

Yes not a problem to the serial now i know …  
To the activeX system it’s old function to a computer but i work on industrial automatism and to include activeX is a new function on automatism side (2 years).
