There is an application with full functionality. This application is for one type of user. They can edit / delete / add. But there are other users who can not do this.

Which way to go, that would not create several similar applications, but with slight differences in functionality?

In Delphi, I used this approach.

#IFDEF DISPATCHER ... #ENDIF #IFDEF VIEWER ... #ENDIF 

In VisualStudio for some reason

 #if DEBUG // Работает #endif #if RELEASE // Не работает #endif 
  • You can, in theory, define custom characters in the code or project properties. - VladD
  • Authorization by password with elevation of rights or installation of user rights based on the rights of the current OS user is not an option? Conditional compilation symbols are not the best choice. Having two sources in front of you, you probably cannot tell where it is. And, sooner or later, you will get confused ... - Alexey

1 answer 1

It's all about the project settings. The Debug configuration defaults to the characters DEBUG and TRACE, while the Release configuration defines only TRACE (there is no RELEASE character).

This method will help you:

 #if !DEBUG #endif 

Or this:

 #if DEBUG #else #endif 

Also in the project properties you can define your own symbols for conditional compilation. I do it like this:

studio screenshot

But, generally speaking, settings and configuration files are usually well suited for different modes of operation:

 if (Properties.Settings.Default.CanEditFoo) { // ... } 

It also makes sense to restrict user access on the server side or DBMS. If your organization uses Active Directory, then a good solution would be to authorize users based on the domain groups to which they belong.

  • It is worth adding that, even without a domain and AD, you can focus on local user groups. This is used by all Windows system software, including SQL and many third-party programs like antiviruses, backup systems, etc. Creating the appropriate local groups can be transferred to the installer or configurator. Here is a very clear example - MS SQL Server installer or Oracle Server. - rdorn
  • @rdorn is more of a non-visual example. Still, for network DBMS, local users and groups are usually useless. - Pavel Mayorov
  • No, not in the sense of an example of use, I myself wrote the blame not successfully, but in the sense of creating and configuring such groups in the configuration process. Well, an independent server may simply not have other groups, although this is an exception rather than normal practice - rdorn