【问题标题】:how to pass dynamic value in __declspec(uuid(" ComObjectGUID ") )如何在 __declspec(uuid(" ComObjectGUID") ) 中传递动态值
【发布时间】:2012-09-23 06:25:36
【问题描述】:

在我的代码中,这绝对没问题:

class __declspec(uuid("842E12D3-1F2C-435D-8426-BE42150AF4DB")) guid;

但不是传递一个 staitc 值,我想传递这样的东西,但它给出了编译错误:

string result("64ca9bdb-08d2-45f7-c526-8fcaa8d5abd1");
class __declspec(uuid(result)) guid; 

//"result" will have dynamic value and that's why want to pass it a variable rather than hard coding the value

有人可以建议我如何实现这一点。

谢谢, 萨南

【问题讨论】:

    标签: c++ uuid declspec


    【解决方案1】:

    这看起来像是在编译时使用的东西。所以没有办法传递动态值。

    【讨论】:

    • 但是是否可以传递变量而不是传递实际值。因为我需要传递具有实际值的“结果”。
    • 您好,编译时确实不能传递动态值,但是运行时可以像这样传递:UUID uuid;字符串结果(“{822412D3-745C-535D-8676-BE41230AF4DB}”); UuidFromString((RPC_CSTR)result.c_str(), &uuid);然后你可以在任何你想要的地方传递或分配 uuid。
    猜你喜欢
    • 2011-09-07
    • 2013-04-09
    • 1970-01-01
    • 2021-09-06
    • 2021-11-25
    • 2021-12-09
    • 2013-06-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多