#include <ntddk.h>
#include <string.h>
.....
PWCHAR tmpBuf = NULL, pwBuf = NULL;;
tmpBuf = ExallocatePoolWithTag(NonPagePool, (MAX_SIZE + 1) * sizeof(WCHAR), BUFFER_TAG);
pwBuf = ExAllocatePoolWithTag(NonPagedPool, (MAX_SIZE + 1) * sizeof(WCHAR), BUFFER_TAG);
RtlStringCchPrintfW(tmpBuf, MAX_SIZE + 1, L"ws", ProcName);
pwBuf = wcstok(tmpBuf, L"\\");
...
错误消息:
错误LNK2019:函数中引用的未解析外部符号_wcstok
但。wcslen
工程
发布于 2016-01-18 05:32:11
微软可能试图迫使你使用wsctok_s
,而不是标准的但不可重入的wsctok
,尤其是在与Windows内核链接的设备驱动程序代码中。
如果strtok_s
也缺失了,那就意味着内核和驱动程序开发的C库是不完整的。您处于托管环境中,标准C库的部分内容可能会丢失。
请注意,您没有使用wcstok()
的旧原型:微软在其VisualStudio 2015中更改了wcstok
的原型,以使其符合C标准:
wchar_t *wcstok(wchar_t *restrict ws1, const wchar_t *restrict ws2,
wchar_t **restrict ptr);
最好避免使用此函数,并将代码更改为直接使用wcschr()
。
如果wcschr
也丢失了,请使用以下简单实现:
/* 7.29.4.5 Wide string search functions */
wchar_t *wcschr(const wchar_t *s, wchar_t c) {
for (;;) {
if (*s == c)
return (wchar_t *)s;
if (*s++ == L'\0')
return NULL;
}
}
以下是wcstok()
的标准一致性实现
wchar_t *wcstok(wchar_t *restrict s1, const wchar_t *restrict s2,
wchar_t **restrict ptr) {
wchar_t *p;
if (s1 == NULL)
s1 = *ptr;
while (*s1 && wcschr(s2, *s1))
s1++;
if (!*s1) {
*ptr = s1;
return NULL;
}
for (p = s1; *s1 && !wcschr(s2, *s1); s1++)
continue;
if (*s1)
*s1++ = L'\0';
*ptr = s1;
return p;
}
https://stackoverflow.com/questions/34847533
复制相似问题