hNdisPwr = CreateFile((PTCHAR)NDISPWR_DEVICE_NAME,
0x00,0x00,NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
(HANDLE)INVALID_HANDLE_VALUE);
returns INVALID_HANDLE_VALUE. Calling GetLastError returns 6.
Any help would be appreciated.
>I am trying to find a way to disable networking on a WM5 device. I found a
>code sample at
>http://devwince.blogspot.com/2008/09/controlling-ethernet-adapter-using.html
>that seems to do this. However, when I implement it I have found that the
>CreateFile function:
>
>hNdisPwr = CreateFile((PTCHAR)NDISPWR_DEVICE_NAME,
I don't recognize NDISPWR_DEVICE_NAME and you didn't include a
definition. But my hunch is that it's char, so you used a cast to
eliminate the compiler error. That won't work. More specifically, you
need to declare a WCHAR array, use MultibyteToWideChar to convert, and
then pass the WCHAR array. If I'm right, then the more general issue
is that you really need to take time to understand UNICODE, or you'll
waste a lot of your time tracking down odd errors like this.
> 0x00,0x00,
Why 0x00 rather than 0? They evaluate to the same value, so it makes
no real difference. But I, at least, found 0x00 distracting.
NULL,
> OPEN_EXISTING,
> FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
I'm pretty sure FILE_FLAG_OVERLAPPED is not supported for Windows CE,
and thus platforms (like Windows Mobile) based on it. Check your
documentation for the function.
> (HANDLE)INVALID_HANDLE_VALUE);
>
>returns INVALID_HANDLE_VALUE. Calling GetLastError returns 6.
>
>Any help would be appreciated.
>
>
-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).
Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 400
Boston, MA 02116
www.penfact.com
Paul T.
hNdis = ::CreateFile(DD_NDIS_DEVICE_NAME, GENERIC_READ
|GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS,0,
(HANDLE)INVALID_HANDLE_VALUE);
BOOL ret = DeviceIoControl(hNdis, IOCTL_NDIS_GET_ADAPTER_NAMES, NULL, 0,
pvNameBuf, sizeof(Buffer), &dwRet ,NULL);
I was then able to disable the devices using the DeviceIoControl and
SetDevicePower functions.
"Marc Oden" <mo...@avioninc.com> wrote in message
news:0EA24C7C-03A2-45E9...@microsoft.com...