gpt4 book ai didi

c++ - '昏暗' : identifier not found

转载 作者:行者123 更新时间:2023-11-30 03:06:15 25 4
gpt4 key购买 nike

我收到此错误消息:

error C3861: 'dim': identifier not found

这是我的包括:

#include "stdafx.h"
#include "HSMBTPrintX.h"
#include "HSMBTPrintXCtrl.h"
#include "HSMBTPrintXPropPage.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#endif

这是我的功能:

#define MSS_PORTS_BASE _T("Software\\Microsoft\\Bluetooth\\Serial\\Ports")
bool FindBluetoothPort(TCHAR name[16]) {
HKEY hKey, hRoot;
TCHAR szPort[20] = _T(""), szPortString[20];
DWORD len, dwIndex=0;
bool bFound=false;
INT i = 0, rc;
DWORD dwNSize;
DWORD dwCSize;
TCHAR szClass[256];
TCHAR szName[MAX_PATH];
FILETIME ft;
hRoot = HKEY_LOCAL_MACHINE;
if (RegOpenKeyEx (hRoot, MSS_PORTS_BASE, 0, 0, &hKey) != ERROR_SUCCESS) {
rc = GetLastError();
return 0;
}
dwNSize = dim(szName); <---- ~~ !! HERE IS THE LINE THAT ERRORS
dwCSize = dim(szClass); <---- HERE IS THE LINE THAT ERRORS !!
rc = RegEnumKeyEx (hKey, i, szName, &dwNSize, NULL, szClass, &dwCSize, &ft);
while (rc == ERROR_SUCCESS)
{
// how many children
TCHAR szCurrentKey[MAX_PATH];
wcscpy(szCurrentKey, MSS_PORTS_BASE);
wcscat(szCurrentKey, TEXT("\\"));
wcscat(szCurrentKey, szName);
wcscat(szCurrentKey, TEXT("\\"));
len = sizeof(szPort);
if(RegGetValue(hRoot, szCurrentKey, _T("Port"), NULL, (LPBYTE)szPort, &len)) {
wsprintf(szPortString, _T("%s:"), szPort);
bFound = true;
break;
}
dwNSize = dim(szName);
rc = RegEnumKeyEx(hKey, ++i, szName, &dwNSize, NULL, NULL, 0, &ft);
}

if(bFound)
_tcscpy(name, szPortString);

return bFound;
}

如您所见,使用它的两行是:

dwNSize = dim(szName);

dwCSize = dim(szClass);

为什么会出错?

最佳答案

看起来你想要sizeof:

dwNSize = sizeof(szName);
dwCSize = sizeof(szClass);

sizeof 返回对象/变量的字节数。但是,我刚刚查看了 API RegEnumKeyEx 的文档,它需要字符数。所以我认为它实际上应该除以 TCHAR 的大小(这将是 1 或 2,具体取决于您是否为 Unicode 构建)。

dwNSize = sizeof(szName) / sizeof(TCHAR);
dwCSize = sizeof(szClass) / sizeof(TCHAR);

关于c++ - '昏暗' : identifier not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6822681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com