C++ GetVolumeInformation错误

C++ GetVolumeInformation错误,c++,c++-cli,C++,C++ Cli,因此,我遇到编译错误,我尝试使用GetVolumeInformation序列化驱动器,这对于每个人来说都是唯一的。任何帮助都将不胜感激 这是我的密码: #include "stdafx.h" #include "Head.h" using namespace System; using namespace System::Collections::Generic; using namespace System::ComponentModel; using namespace System::D

因此,我遇到编译错误,我尝试使用GetVolumeInformation序列化驱动器,这对于每个人来说都是唯一的。任何帮助都将不胜感激

这是我的密码:

#include "stdafx.h"
#include "Head.h"

using namespace System;
using namespace System::Collections::Generic;
using namespace System::ComponentModel;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Text;
using namespace System::Net;
using namespace System::Net::Sockets;
using namespace System::Windows::Forms;
using namespace System::IO;
using namespace System::Security::Cryptography;
using namespace System::Security::Principal;

namespace SE
{

    String ^Base::GetSerial(String ^strDriveLetter)
    {
        UInt32 serNum = 0;
        UInt32 maxCompLen = 0;
        StringBuilder ^VolLabel = gcnew StringBuilder(256); // Label
        UInt32 VolFlags = UInt32();
        StringBuilder ^FSName = gcnew StringBuilder(256); // File System Name
        strDriveLetter += ":\\"; // fix up the passed-in drive letter for the API call
        bool Ret = GetVolumeInformation(strDriveLetter, VolLabel, safe_cast<UInt32>(VolLabel->Capacity), serNum, maxCompLen, VolFlags, FSName, safe_cast<UInt32>(FSName->Capacity));
        return Convert::ToString(serNum);
    }
}
然而,当我编译时,我得到:

error LNK2022: metadata operation failed (80131187) : Inconsistent method declarations in duplicated types (types: SE.Base; methods: GetVolumeInformationA): (0x06000008).

我有什么不对劲吗?谢谢

我不确定,但我认为问题可能是因为GetVolumeInformation函数是一个静态函数,所以需要将其称为

    Base::GetVolumeInformation

在函数字符串^Base::GetSerial中。请尝试此操作,看看是否有效。

Head.h文件导致此问题,同一类声明包含在多个翻译单元中,链接器发现它们之间不匹配。首先删除private,这是无效的。
    Base::GetVolumeInformation