NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Set the PropFlags using API's

Solved!
Go to solution

Hi,

 

I have created a new group using the API calls in C#. I need to ensure that the newly created group is not deleted. So I tried using the SetFlag method to set these property flags.

The code snippet is as 

 

 userGroup = eng.NewUser(null);

 userGroup.LoginName = "Test";

 userGroup.AsPropertyObject().SetFlags("PropFlags_NotDeletable", 0x1, 0x400000);
 userGroup.AsPropertyObject().SetFlags("PropFlags_NameNotEditable", 0x1, 0x400000);

 

However, the newly created group does not have these flags set.

How do I go about setting these flags?

 

Thanks

Arun

0 Kudos
Message 1 of 12
(4,033 Views)

Hi Arun,

 

You did NewUser(NULL) that means you have created a user without a profile!

You should add a profile to the new user than it should work and you can get rid of SetFlags

 

 

Hope this helps

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 2 of 12
(4,013 Views)

Hi Juergen,

 

Thanks for your response. I guess I have not reported my problem clearly. 

I am fairly new to TestStand so I may be wrong about this; the User Group in TestStand is also of User datatype.

I have created a new group by using the eng.NewUser(null) call.

This newly created group should not be editable or deletable. With this in mind, I used the SetFlags() API call. I now have a new group with name Test, however the appropriate propFlags are not set for the group.

How do I go about setting these flags using API's?

 

Please advise.

 

Thanks

Arun

 

0 Kudos
Message 3 of 12
(4,008 Views)

Hi, Arun

 

Why don't you create the new user with User Manager ?

(Just press STRG-U) because it provides you an easy to use interface
here you can also set the flags.

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 4 of 12
(4,005 Views)

Hi Juergen,

 

I am building a C# wrapper around the User Management module of TestStand. So have to work only with API's.

 

Thanks

Arun

 

 

0 Kudos
Message 5 of 12
(4,003 Views)

Hi,

 

Ok clear, thanks

and when a you run your Wrapper you should be able to login into TestStand with the created user, right ?

 

Juergen

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 6 of 12
(4,000 Views)

Hi

 

Try this example.

 

Hope this helps

 

juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 7 of 12
(3,997 Views)
Solution
Accepted by topic author Arun Padmanabhan

You are passing incorrect arguments to the SetFlags function. The first parameter is the lookup string of the property you want to set the flags on. In this case, pass an empty string to refer to the User object itself. The second parameter specifies function options. In this case you need none. The third parameter specifies the flags you want set on the property. You need to pass the combination of flags (PropFlags_NotDeletable | PropFlags_NameNotEditable). If you call SetFlags function again, it will overwrite the flags you set in previous calls.

 

 userGroup.AsPropertyObject().SetFlags("", 0x0, PropFlags_NotDeletable | PropFlags_NameNotEditable);

 

Message 8 of 12
(3,994 Views)

Hi Juergen,

 

Thanks for all your assistance. However, my mistake lay where Erik pointed out. I was passing the wrong parameters in the SetFlags() method. I have accordingly changed the parameters and the problem is fixed.

 

Regards

Arun

0 Kudos
Message 9 of 12
(3,968 Views)

Hi Erik,

 

Thank you for pointing out the error in my code. I have rectified it as per your suggestion and now the behaviour is as expected.

 

Thanks

Arun

 

0 Kudos
Message 10 of 12
(3,967 Views)