如何更改#define
How can I change #define
如何更改#define TRIAL为#define PREMIUM,当用户输入一些注册键时。
谢谢。
//#define TRIAL
#define PREMIUM
using System;
using System.Diagnostics;
using System.Reflection;
namespace Attributes
{
[Obsolete("This is an old class. Use new class instead!")]
class Test
{
[Conditional("TRIAL")]
void Trial()
{
Console.WriteLine("Trial");
}
[Conditional("PREMIUM")]
void Release()
{
Console.WriteLine("PREMIUM");
}
......................................
听起来您可能误解了预处理器指令。您应该将这类信息以某种方式加密存储在用户的机器上,并将其加载到变量中,或者更好的方法是发布两个带有升级选项的版本。这将更加稳定和安全。
如果您选择采用这种方法,那么您可以使用预处理器指令为每个程序的发行版本编译不同版本的库和代码。
#define是编译时指令,所以你不能使用它…相反,您应该使用传统的if:
class Test
{
void DoAction() {
if(trial) { Console.WriteLine("Trial"); }
else { Console.WriteLine("PREMIUM");
}
}
相关文章:
- 如何在Qt C++中更改光标
- 为什么++(*p)更改指针值
- 如何通过派生类函数更改基类中的向量
- 函数何时会在c++中包含stack_Unwind_Resume调用
- C++ 使用 assign 函数的字符串与直接使用 '=' 更改值的字符串之间的区别
- TDateTime格式在C++Builder中不会更改
- 查找后更改类变量
- 为什么我无法更改"set<set>"循环中的值<int>
- Xaudio2在更改缓冲区或循环时弹出声音
- Python中的for循环与C++有何不同
- 如何在Qbutton的帮助下更改Q对话框的宽度
- 在更改for循环的第三部分后,未使用for循环结果
- 从 #define 更改为 const(大写?
- 如何使用宏 #define 更改类名
- 将所有 int 类型更改为另一种类型,使用 #define 用于大型程序
- 是否可以使用#define更改#include文件名
- CPP -在库中更改#define
- 如何更改#define
- 在 C 中,除了使用 val 之外,不能更改结构属性 #define
- 添加预处理器#define来更改包含哪些头文件以及调用哪些函数