Пример #1
0
/**
 * Construct a new host folder PIDL with the fields initialised.
 */
inline winapi::shell::pidl::cpidl_t create_host_itemid(
    const std::wstring& host, const std::wstring& user, 
    const boost::filesystem::wpath& path, int port,
    const std::wstring& label=std::wstring())
{
    // We create the item on the stack and then clone it into 
    // a CoTaskMemAllocated pidl when we return it as a cpidl_t
    detail::host_item_template item;
    std::memset(&item, 0, sizeof(item));

    item.id.cb = sizeof(item.id);
    item.id.dwFingerprint = detail::host_item_id::FINGERPRINT;

#pragma warning(push)
#pragma warning(disable:4996)
    host.copy(item.id.wszHost, MAX_HOSTNAME_LENZ);
    item.id.wszHost[MAX_HOSTNAME_LENZ - 1] = wchar_t();

    user.copy(item.id.wszUser, MAX_USERNAME_LENZ);
    item.id.wszUser[MAX_USERNAME_LENZ - 1] = wchar_t();

    path.string().copy(item.id.wszPath, MAX_PATH_LENZ);
    item.id.wszPath[MAX_PATH_LENZ - 1] = wchar_t();

    label.copy(item.id.wszLabel, MAX_LABEL_LENZ);
    item.id.wszLabel[MAX_LABEL_LENZ - 1] = wchar_t();
#pragma warning(pop)

    item.id.uPort = boost::numeric_cast<USHORT>(port);

    assert(item.terminator.cb == 0);

    return winapi::shell::pidl::cpidl_t(
        reinterpret_cast<PCITEMID_CHILD>(&item));
}
Пример #2
0
void TrayIcon::setToolTip(const std::wstring& toolTip)
{
    DWORD tipSize;
    if (this->nid.cbSize == sizeof(NOTIFYICONDATAW_V1_SIZE))
    {
        tipSize = 64;
    }
    else
    {
        tipSize = 128;
    }
    tipSize = static_cast<DWORD>(toolTip.copy(this->nid.szTip, tipSize - 1));
    this->nid.szTip[tipSize] = L'\0';
}