本文整理汇总了C++中wprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ wprintf函数的具体用法?C++ wprintf怎么用?C++ wprintf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DriverUnload
BOOL DriverUnload ()
{
SC_HANDLE hManager = NULL, hService = NULL;
BOOL bRet = FALSE;
SERVICE_STATUS status = {0};
int x = 0;
hManager = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (hManager == NULL)
goto error;
hService = OpenService (hManager, L"Bluefisher", SERVICE_ALL_ACCESS);
if (hService == NULL)
{
wprintf( L"Open Service for Bluefisher was failed. Error: %d.\n", GetLastError() );
SetLastError(0);
goto error;
}
bRet = QueryServiceStatus (hService, &status);
if (bRet != TRUE)
{
wprintf( L"Query Service status failed. Error: %d.\n", GetLastError() );
SetLastError(0);
goto error;
}
if (status.dwCurrentState != SERVICE_STOPPED)
{
ControlService (hService, SERVICE_CONTROL_STOP, &status);
for (x = 0; x < 5; x++)
{
bRet = QueryServiceStatus (hService, &status);
if (bRet != TRUE)
{
wprintf( L"Query Service status failed. Loop %d. Error: %d.\n", x, GetLastError() );
SetLastError(0);
goto error;
}
if (status.dwCurrentState == SERVICE_STOPPED)
break;
Sleep (200);
}
}
DeleteService( hService );
error:
if (hService != NULL)
CloseServiceHandle (hService);
if (hManager != NULL)
CloseServiceHandle (hManager);
if (status.dwCurrentState == SERVICE_STOPPED)
{
//hDriver = INVALID_HANDLE_VALUE;
return TRUE;
}
return FALSE;
}
示例2: main
int main() {
SOCKET master = INVALID_SOCKET;
struct sockaddr_in server, client;
struct sockaddr_in broadcast;
char recvbuf[BUFLEN] = "";
int iResult;
WSADATA wsaData;
int count;
char str[INET_ADDRSTRLEN];
char *message = "I am server";
int addrlen = sizeof(client);
int clientListenPorts[CLIENTS],cp;
int i;
fd_set read;
for (i = 0; i < CLIENTS; i++) {
clientListenPorts[i] = 0;
}
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != NO_ERROR) {
wprintf(L"WSAStartup failed with error: %d\n", iResult);
return 1;
}
printf("Winsock initialized\n");
//create socket
master = socket(AF_INET, SOCK_DGRAM, 0);
if (master == INVALID_SOCKET) {
wprintf(L"master socket failed with error: %ld\n", WSAGetLastError());
WSACleanup();
return 1;
}
printf("Socket created\n");
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons(SERVER_PORT);
//bind
if (bind(master, (struct sockaddr *)&server, sizeof(server)) < 0) {
printf("bind() failed : %d\n", WSAGetLastError());
exit(EXIT_FAILURE);
}
printf("Binding done\n");
while (TRUE) {
fflush(stdout);
//clear the buffer
memset(recvbuf, '\0', BUFLEN);
//receive data
if ((count = recvfrom(master, recvbuf, BUFLEN, 0, (struct sockaddr *) &client, &addrlen))
== SOCKET_ERROR)
{
printf("recvfrom() failed with error code : %d", WSAGetLastError());
exit(EXIT_FAILURE);
}
printf("Received from client , ip %s, port %d \n",
inet_ntop(AF_INET, &(client.sin_addr), str, INET_ADDRSTRLEN), ntohs(client.sin_port));
printf("My listening port is: %s\n", recvbuf);
sscanf_s(recvbuf, "%d", &cp);
for (i = 0; i < CLIENTS; i++)
{
if (clientListenPorts[i] == 0)
{
clientListenPorts[i] = cp;
printf("Adding to list of client listen ports at index %d \n", i);
break;
}
}//end for
/*iResult = sendto(master, (char*)clientListenPorts, CLIENTS*sizeof(int), 0, (struct sockaddr *)&client,
addrlen);
if (iResult == SOCKET_ERROR)
{
printf("sendto() failed with error code : %d", WSAGetLastError());
exit(EXIT_FAILURE);
}*/
//create socket
//broadcast
int options = 1;
if ((setsockopt(master, SOL_SOCKET, SO_BROADCAST, (void *)&options, sizeof(options))) < 0) {
printf("%d", WSAGetLastError());
//.........这里部分代码省略.........
示例3: MonitorPrintUsage
void
MonitorPrintUsage()
{
wprintf(L"Usage: monitor ( addcallouts | delcallouts | monitor <targetApp.exe> )\n");
}
示例4: httpd_www_conf_dialog
__inline__ void httpd_www_conf_dialog(int fd, char *action, int confidx, char *curval, char *submit_cpt) {
wprintf(fd, "<FORM ACTION=\"%s\" METHOD=\"GET\">\n", action);
wprintf(fd, "<TABLE BORDER=\"0\" ALIGN=\"CENTER\" VALIGN=\"MIDDLE\">\n");
wprintf(fd, "<TR><TD ALIGN=\"CENTER\">Current value: %s</TD></TR>\n", curval);
wprintf(fd, "</TABLE>\n");
wprintf(fd, "<BR>\n");
wprintf(fd, "<TABLE BORDER=\"1\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"35%\" ALIGN=\"CENTER\" VALIGN=\"MIDDLE\">\n");
wprintf(fd, "<TR>\n");
wprintf(fd, "<TD COLSPAN=\"2\">\n");
wprintf(fd, "New value: <INPUT SIZE=\"24\" TYPE=\"TEXT\" NAME=\"newval\">\n");
wprintf(fd, "<INPUT READONLY TYPE=\"HIDDEN\" NAME=\"idx\" VALUE=\"%d\">\n", confidx);
wprintf(fd, "</TD>\n");
wprintf(fd, "</TR>\n");
wprintf(fd, "<TR>\n");
wprintf(fd, "<TD ALIGN=\"CENTER\"><INPUT TYPE=SUBMIT VALUE=\"%s\"></TD>\n", submit_cpt);
wprintf(fd, "<TD ALIGN=\"CENTER\"><INPUT TYPE=RESET VALUE=\"clear\"></TD>\n");
wprintf(fd, "</FORM>\n");
wprintf(fd, "</TD>\n");
wprintf(fd, "</TR>\n");
wprintf(fd, "</TABLE>\n");
return ;
}
示例5: httpd_www_about
int httpd_www_about(int fd, char *raw, char *cgi) {
httpd_start_hmenu(fd, NULL);
httpd_end_hmenu(fd);
wprintf(fd, "<BR>\n");
wprintf(fd, "<TABLE BORDER=\"1\" CELLPADDING=\"0\" CELLSPACING=\"0\" ALIGN=\"CENTER\" VALIGN=\"TOP\">\n");
wprintf(fd, "<TR>\n");
wprintf(fd, "<TD ALIGN=\"CENTER\" VALIGN=\"MIDDLE\">\n");
wprintf(fd, "Ghost (v/%s)\n", GHOST_VERSION);
wprintf(fd, "</TD>\n");
wprintf(fd, "</TR>\n");
wprintf(fd, "</TABLE>\n");
wprintf(fd, "<BR>\n");
wprintf(fd, "<TABLE BORDER=\"1\" CELLPADDING=\"0\" CELLSPACING=\"0\" ALIGN=\"CENTER\" VALIGN=\"BOTTOM\">\n");
wprintf(fd, "<TR>\n");
wprintf(fd, "<TD ALIGN=\"CENTER\" VALIGN=\"MIDDLE\">\n");
wprintf(fd, "<A HREF=\"http://www.ikotler.org\">http://www.ikotler.org</A>\n");
wprintf(fd, "</TD>\n");
wprintf(fd, "</TR>\n");
wprintf(fd, "<TR>\n");
wprintf(fd, "<TD ALIGN=\"CENTER\" VALIGN=\"MIDDLE\">\n");
wprintf(fd, "<A HREF=\"mailto:[email protected]\">[email protected]</A>\n");
wprintf(fd, "</TR>\n");
wprintf(fd, "</TABLE>\n");
wprintf(fd, "<BR>\n");
return 1;
}
示例6: WinMain
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*prevInstance*/,
PSTR /*cmdLine*/, int /*showCmd*/)
{
//notify user if heap is corrupt
#if defined _DEBUG
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
#endif
#pragma region junk
//***********************
//get command line params
//LPCWSTR
int numArgs=0;
WCHAR **sArgList = CommandLineToArgvW(GetCommandLineW(), &numArgs);
//print arguments
if( NULL == sArgList )
{
wprintf(L"CommandLineToArgvW failed\n");
return 0;
}
else
{
wstringstream strstr;
for(int i=0; i < numArgs; i++)
{
strstr << i << sArgList[i] << _T("\n");
}
OutputDebugStringW(strstr.str().c_str());
}
LocalFree(sArgList);//free memory
//end of parameters experiment
//****************************
#pragma endregion
//create game singleton object
Engine* pEngine = new Engine(hInstance);
MainGame* pGame = new MainGame();
#if defined DEBUG || _DEBUG
cout << "-Engine & Game created\n";
#endif
pEngine->SetGame(pGame);
pEngine->Initialize();
#if defined DEBUG || _DEBUG
cout << "------------------------\n:::Engine Initialized:::\n------------------------\n\n";
#endif
int ret = pEngine->Run();
//destroy objects
delete pGame;
delete pEngine;
cout << "\n\n";
cout << " Happy Engine wishes you a happy day! \n";
cout << "--------------\\Press any key/-------------\n";
cin.get();
#if defined _DEBUG
_CrtDumpMemoryLeaks();
#endif
return ret;
}
示例7: httpd_www_proxies
int httpd_www_proxies(int fd, char *raw, char *cgi) {
int idx, p_counter;
proxy_entry *cur_proxy;
proxy_db_stats *cur_db;
cur_db = proxy_get_stats();
if (!cur_db) {
httpd_www_syserr(fd, "calloc", raw);
return 0;
}
httpd_start_hmenu(fd, proxies_menu);
httpd_end_hmenu(fd);
if (cur_db->index < 1) {
httpd_www_label(fd, "There are no proxies in the database!", 45);
free(cur_db);
return 1;
}
httpd_www_label(fd, "Proxies Database", 80);
wprintf(fd, "<TABLE BORDER=\"1\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"85%\" ALIGN=\"CENTER\" VALIGN=\"MIDDLE\">\n");
wprintf(fd, "\t<TR>\n");
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\">#</TD>\n");
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\">proxy address</TD>\n");
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\">proxy port</TD>\n");
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\">proxy rank</TD>\n");
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\">proxy strikes</TD>\n");
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\">proxy jobs</TD>\n");
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\" COLSPAN=\"3\">proxy options</TD>\n");
wprintf(fd, "\t</TR>\n");
p_counter = 1;
for (idx = 0; idx < cur_db->index; idx++) {
cur_proxy = proxy_querydb(idx);
if (!cur_proxy) {
continue;
}
wprintf(fd, "\t<TR>\n");
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\">%d</TD>\n", p_counter);
wprintf(fd, "\t\t<TD>%s</TD>\n", cur_proxy->addr);
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\">%d</TD>\n", cur_proxy->port);
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\">%s</TD>\n", proxy_getrank(cur_proxy));
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\">%d</TD>\n", cur_proxy->strikes);
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\">%d</TD>\n", cur_proxy->jobs);
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\"><A HREF=\"/proxy-checkup.cgi?id=%d\">validate</A></TD>\n", idx);
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\"><A HREF=\"/proxy-modifier.cgi?id=%d\">modify</A></TD>\n", idx);
wprintf(fd, "\t\t<TD ALIGN=\"CENTER\"><A HREF=\"/delete-proxy.cgi?id=%d\">delete</A></TD>\n", idx);
wprintf(fd, "\t</TR>\n");
p_counter++;
free(cur_proxy);
}
wprintf(fd, "</TABLE>\r\n");
free(cur_db);
return 1;
}
示例8: MyMiniDumpCallback
BOOL CALLBACK MyMiniDumpCallback(
PVOID pParam,
const PMINIDUMP_CALLBACK_INPUT pInput,
PMINIDUMP_CALLBACK_OUTPUT pOutput
)
{
BOOL bRet = FALSE;
// Check parameters
if( pInput == 0 )
return FALSE;
if( pOutput == 0 )
return FALSE;
// Process callbacks
switch( pInput->CallbackType )
{
case IncludeModuleCallback:
{
// Include the module into the dump
_tprintf( _T("IncludeModuleCallback (module: %08I64x) \n"),
pInput->IncludeModule.BaseOfImage);
bRet = TRUE;
}
break;
case IncludeThreadCallback:
{
// Include the thread into the dump
_tprintf( _T("IncludeThreadCallback (thread: %x) \n"),
pInput->IncludeThread.ThreadId);
bRet = TRUE;
}
break;
case ModuleCallback:
{
// Include all available information
wprintf( L"ModuleCallback (module: %s) \n", pInput->Module.FullPath );
bRet = TRUE;
}
break;
case ThreadCallback:
{
// Include all available information
_tprintf( _T("ThreadCallback (thread: %x) \n"), pInput->Thread.ThreadId );
bRet = TRUE;
}
break;
case ThreadExCallback:
{
// Include all available information
_tprintf( _T("ThreadExCallback (thread: %x) \n"), pInput->ThreadEx.ThreadId );
bRet = TRUE;
}
break;
case MemoryCallback:
{
// Let CancelCallback know where to stop
MemoryCallbackCalled = true;
// We do not include any information here -> return FALSE
_tprintf( _T("MemoryCallback\n") );
bRet = FALSE;
}
break;
/* no longer valid option? erno 08-01
case CancelCallback:
{
_tprintf( _T("CancelCallback\n") );
if( !MemoryCallbackCalled)
{
// Continue receiving CancelCallback callbacks
pOutput->Cancel = FALSE;
pOutput->CheckCancel = TRUE;
}
else
{
// No cancel callbacks anymore
pOutput->Cancel = FALSE;
pOutput->CheckCancel = FALSE;
}
bRet = TRUE;
}
break;
*/
}
return bRet;
//.........这里部分代码省略.........
示例9: ParseCommandLine
BOOL ParseCommandLine( int argc, wchar_t *argv[ ])
{
/*
** PARSE the FOLLOWING ARGUMENTS:
/LDAP <Path of container>
ADsPath of the container for placing the new group
/UNAME <NT 5 User Name>
This is the name for the new group
/SAMNAME <Downlevel NT 4 Sam Account name>
Cannot exceed 20 characters and must be globally unique
<*> Detailed New User information <*>
/FILE < Info File >
Filename for file to contain new user information
<*> OPTIONAL Binding Information <*>
/USER <User name used for binding to the DC>
/PASS <Password used for binding to the DC>
(If these are passed, binding is done with ADsOpenObject())
*/
if (argc == 1)
{
_putws(pwszUsage);
return FALSE;
}
for (int x= 1; x < argc; x++)
{
if (_wcsicmp(argv[x],L"/LDAP")==0)
{
if (argc == x) // Make sure the parameter was passed
{
wprintf(L"\nERROR: %s Missing parameter!!!!\n\n",argv[x]);
_putws(pwszUsage);
return FALSE;
}
// Go to the next argument and save it in module level variable
x++;
bsLDAP = SysAllocString(argv[x]);
}
else if (_wcsicmp(argv[x],L"/UNAME")==0)
{
if (argc == x) // Make sure the parameter was passed
{
wprintf(L"\nERROR: %s Missing parameter!!!!\n\n",argv[x]);
_putws(pwszUsage);
return FALSE;
}
// Go to the next argument and save it in module level variable
x++;
bsUNAME = SysAllocString(argv[x]);
}
else if (_wcsicmp(argv[x],L"/SAMNAME")==0)
{
if (argc == x) // Make sure the parameter was passed
{
wprintf(L"\nERROR: %s Missing parameter!!!!\n\n",argv[x]);
_putws(pwszUsage);
return FALSE;
}
// Go to the next argument and save it in module level variable
x++;
bsSAMNAME = SysAllocString(argv[x]);
}
else if (_wcsicmp(argv[x],L"/FILE")==0)
{
if (argc == x) // Make sure the parameter was passed
{
wprintf(L"\nERROR: %s Missing parameter!!!!\n\n",argv[x]);
_putws(pwszUsage);
return FALSE;
}
// Go to the next argument and save it in module level variable
x++;
bsFILE = SysAllocString(argv[x]);
}
else if (_wcsicmp(argv[x],L"/USER")==0)
{
if (argc == x) // Make sure the parameter was passed
{
wprintf(L"\nERROR: %s Missing parameter!!!!\n\n",argv[x]);
_putws(pwszUsage);
return FALSE;
}
// Go to the next argument and save it in module level variable
x++;
bsUSER = SysAllocString(argv[x]);
}
else if (_wcsicmp(argv[x],L"/PASS")==0)
{
if (argc == x) // Make sure the parameter was passed
{
wprintf(L"\nERROR: %s Missing parameter!!!!\n\n",argv[x]);
_putws(pwszUsage);
return FALSE;
}
// Go to the next argument and save it in module level variable
//.........这里部分代码省略.........
示例10: ControllerDMA_NAOMI
//.........这里部分代码省略.........
{
State.Mode=1;
State.Cmd=buffer_in_b[8];
State.Node=buffer_in_b[9];
buffer_out_len=0;
}
return (7);
case 0x21: //Transfer request with repeat
{
State.Mode=2;
State.Cmd=buffer_in_b[8];
State.Node=buffer_in_b[9];
buffer_out_len=0;
}
return (7);
case 0x0B: //EEPROM write
{
int address=buffer_in_b[1];
int size=buffer_in_b[2];
//printf("EEprom write %08X %08X\n",address,size);
//printState(Command,buffer_in,buffer_in_len);
memcpy(EEPROM+address,buffer_in_b+4,size);
wchar eeprom_file[512];
host.ConfigLoadStr(L"emu",L"gamefile",eeprom_file,L"");
wcscat_s(eeprom_file,L".eeprom");
FILE* f;
_wfopen_s(&f,eeprom_file,L"wb");
if (f)
{
fwrite(EEPROM,1,0x80,f);
fclose(f);
wprintf(L"SAVED EEPROM to %s\n",eeprom_file);
}
}
return (7);
case 0x3: //EEPROM read
{
if (!EEPROM_loaded)
{
EEPROM_loaded=true;
wchar eeprom_file[512];
host.ConfigLoadStr(L"emu",L"gamefile",eeprom_file,L"");
wcscat_s(eeprom_file,L".eeprom");
FILE* f;
_wfopen_s(&f,eeprom_file,L"rb");
if (f)
{
fread(EEPROM,1,0x80,f);
fclose(f);
wprintf(L"LOADED EEPROM from %s\n",eeprom_file);
}
}
//printf("EEprom READ ?\n");
int address=buffer_in_b[1];
//printState(Command,buffer_in,buffer_in_len);
memcpy(buffer_out,EEPROM+address,0x80);
buffer_out_len=0x80;
}
return 8;
//IF I return all FF, then board runs in low res
case 0x31:
{
buffer_out[0]=0xffffffff;
buffer_out[1]=0xffffffff;
示例11: Usage
VOID
Usage()
{
wprintf(
L"httpcfg ACTION STORENAME [OPTIONS] \n"
L"ACTION -set | query | delete \n"
L"STORENAME -ssl | urlacl | iplisten \n"
L"[OPTIONS] -See Below\n"
L"\n"
L"Options for ssl:\n"
L" -i IP-Address - IP:port for the SSL certificate (record key)\n"
L"\n"
L" -h SslHash - Hash of the Certificate.\n"
L"\n"
L" -g GUID - GUID to identify the owning application.\n"
L"\n"
L" -c CertStoreName - Store name for the certificate. Defaults to\n"
L" MY. Certificate must be stored in the\n"
L" LOCAL_MACHINE context.\n"
L"\n"
L" -m CertCheckMode - Bit Flag\n"
L" 0x00000001 - Client certificate will not be\n"
L" verified for revocation.\n"
L" 0x00000002 - Only cached client certificate\n"
L" revocation will be used.\n"
L" 0x00000004 - Enable use of the Revocation\n"
L" freshness time setting.\n"
L" 0x00010000 - No usage check.\n"
L"\n"
L" -r RevocationFreshnessTime - How often to check for an updated certificate\n"
L" revocation list (CRL). If this value is 0,\n"
L" then the new CRL is updated only if the\n"
L" previous one expires. Time is specified in\n"
L" seconds.\n"
L"\n"
L" -x UrlRetrievalTimeout - Timeout on attempt to retrieve certificate\n"
L" revocation list from the remote URL.\n"
L" Timeout is specified in Milliseconds.\n"
L"\n"
L" -t SslCtlIdentifier - Restrict the certificate issuers that can be\n"
L" trusted. Can be a subset of the certificate\n"
L" issuers that are trusted by the machine.\n"
L"\n"
L" -n SslCtlStoreName - Store name under LOCAL_MACHINE where\n"
L" SslCtlIdentifier is stored.\n"
L"\n"
L" -f Flags - Bit Field\n"
L" 0x00000001 - Use DS Mapper.\n"
L" 0x00000002 - Negotiate Client certificate.\n"
L" 0x00000004 - Do not route to Raw ISAPI\n"
L" filters.\n"
L"\n"
L"Options for urlacl:\n"
L" -u Url - Fully Qualified URL. (record key)\n"
L" -a ACL - ACL specified as a SDDL string.\n"
L"\n"
L"Options for iplisten:\n"
L" -i IPAddress - IPv4 or IPv6 address. (for set/delete only)\n");
}
示例12: printUsage
void printUsage()
{
wprintf(L"\nUSAGE:");
wprintf(L"\n WCNConfigure.exe");
wprintf(L"\n Scenario=[DeviceConfigPin | DeviceConfigPushButton | RouterConfig |");
wprintf(L"\n PCConfigPushButton | PCConfigPin ]");
wprintf(L"\n [UUID=<uuid of device> | SEARCHSSID=<ssid of device to find>]");
wprintf(L"\n [PIN=<pin of device>]");
wprintf(L"\n [PROFILESSID=<ssid to use in profile>]");
wprintf(L"\n [PROFILEPASSPHRASE=<passphrase to use in profile>]");
wprintf(L"\n");
wprintf(L"\nParameters:");
wprintf(L"\n Scenario - choose the operation you wish to perform ");
wprintf(L"\n DeviceConfigPushButton - Configure a WCN enabled device, such as a picture");
wprintf(L"\n frame using the button on the device");
wprintf(L"\n DeviceConfigPin - Configure a WCN enabled device, such as a picture frame");
wprintf(L"\n using the device supplied pin");
wprintf(L"\n RouterConfig - Configure a WCN enabled Wireless Router");
wprintf(L"\n PCConfigPushButton - Get the wireless profile from a WCN enabled router");
wprintf(L"\n using the Push Button on the device.");
wprintf(L"\n PCConfigPin - Get the wireless profile from a WCN enabled rotuer using the");
wprintf(L"\n supplied pin.");
wprintf(L"\n");
wprintf(L"\n UUID - Enter a device UUID in the following format xxxx-xxxx-xxxx-xxxxxxxxxxxx");
wprintf(L"\n UUID is necessary for the DeviceConfigPushButton and DeviceConfigPin");
wprintf(L"\n scenarios. Use either UUID or SEARCHSSID for the RouterConfig, PCConfigPin");
wprintf(L"\n and PCConfigPushButton scenarios.");
wprintf(L"\n");
wprintf(L"\n SEARCHSSID - Enter in the SSID for the Router you are looking to configure.");
wprintf(L"\n SEARCHSSID is only valid in the RouterConfig, PCConfigPushButton and ");
wprintf(L"\n PCConfigPin scenarios. Use either UUID or SEARCHSSID for the these");
wprintf(L"\n scenarios. NOTE: Using SSID will return the first device");
wprintf(L"\n found with that ssid. If there is more than one device with the");
wprintf(L"\n same ssid use the UUID instead");
wprintf(L"\n");
wprintf(L"\n PIN - Enter the pin of the device");
wprintf(L"\n PIN is only valid when using the RouterConfig and DeviceConfigPIN");
wprintf(L"\n Scenarios.");
wprintf(L"\n");
wprintf(L"\n PROFILESSID - When present this SSID will be used in the WLAN profile that is");
wprintf(L"\n pushed to the router/device otherwise a default SSID of WCNSSID ");
wprintf(L"\n will be used");
wprintf(L"\n");
wprintf(L"\n PROFILEPASSPHRASE - when present this passphrase will be used in the wlan");
wprintf(L"\n profile that is pushed to the router/device. Otherwise, a");
wprintf(L"\n random default passphrase will be used\n\n");
}
示例13: GetWCNDeviceInformation
HRESULT GetWCNDeviceInformation(__in IWCNDevice* pDevice, __out WCN_DEVICE_INFO_PARAMETERS* pWCNDeviceInformation)
{
HRESULT hr = ERROR_SUCCESS;
//A WCN device can have a variety of attributes. (These attributes generally correspond
//to TLVs in the WPS specification, although not all WPS TLVs are available as WCN attributes).
//You can use the IWCNDevice::Get*Attribute to read these attributes. Not all devices send
//all attributes -- if the device did not send a particular attribute, the Get*Attribute API
//will return HRESULT_FROM_WIN32(ERROR_NOT_FOUND).
//
//This sample demonstrates how to get the most common attributes that would be useful for
//displaying in a user interface.
//
// WCN_TYPE_DEVICE_NAME
//
//The IWCNDevice::GetStringAttribute method gets a cached attribute from the device as a string.
hr = pDevice->GetStringAttribute(
WCN_TYPE_DEVICE_NAME,
ARRAYSIZE(pWCNDeviceInformation->wszDeviceName),
pWCNDeviceInformation->wszDeviceName);
if (hr != ERROR_SUCCESS)
{
wprintf(L"\nERROR: Failed to get the Device Name from the IWCNDevice instance. hr=[0x%x]", hr);
goto cleanup;
}
wprintf(L"\nINFO: Device Name: [%s]",pWCNDeviceInformation->wszDeviceName);
//
// WCN_TYPE_MANUFACTURER
//
hr = pDevice->GetStringAttribute(
WCN_TYPE_MANUFACTURER,
ARRAYSIZE(pWCNDeviceInformation->wszManufacturerName),
pWCNDeviceInformation->wszManufacturerName);
if (hr != ERROR_SUCCESS)
{
wprintf(L"\nERROR: Failed to get the device manufacturer from the ICWNDevice instance, hr=[0x%x]", hr);
goto cleanup;
}
wprintf(L"\nINFO: Manufacturer Name: [%s]", pWCNDeviceInformation->wszManufacturerName);
//
// WCN_TYPE_MODEL_NAME
//
hr = pDevice->GetStringAttribute(
WCN_TYPE_MODEL_NAME,
ARRAYSIZE(pWCNDeviceInformation->wszModelName),
pWCNDeviceInformation->wszModelName);
if (hr != ERROR_SUCCESS)
{
wprintf(L"\nERROR: Failed to get the device model name from the ICWNDevice instance, hr=[0x%x]", hr);
goto cleanup;
}
wprintf(L"\nINFO: Model Name: [%s]", pWCNDeviceInformation->wszModelName);
//
// WCN_TYPE_MODEL_NUMBER
// Note that the Model Number is actually a string. Most devices have alpha-numeric
// model numbers, like "AB1234CD".
hr = pDevice->GetStringAttribute(
WCN_TYPE_MODEL_NUMBER,
ARRAYSIZE(pWCNDeviceInformation->wszModelNumber),
pWCNDeviceInformation->wszModelNumber);
if (hr != ERROR_SUCCESS)
{
wprintf(L"\nERROR: Failed to get the device model name from the ICWNDevice instance, hr=[0x%x]", hr);
goto cleanup;
}
wprintf(L"\nINFO: Model Number: [%s]", pWCNDeviceInformation->wszModelNumber);
//
// WCN_TYPE_SERIAL_NUMBER
// Note that the Serial Number is actually a string. Some devices send strings that
// aren't meaningful, like "(none)" or just the empty string.
hr = pDevice->GetStringAttribute(
WCN_TYPE_SERIAL_NUMBER,
ARRAYSIZE(pWCNDeviceInformation->wszSerialNumber),
pWCNDeviceInformation->wszSerialNumber);
if (hr != ERROR_SUCCESS)
{
wprintf(L"\nERROR: Failed to get the device model name from the ICWNDevice instance, hr=[0x%x]", hr);
goto cleanup;
}
wprintf(L"\nINFO: Serial Number: [%s]", pWCNDeviceInformation->wszSerialNumber);
//.........这里部分代码省略.........
示例14: RunScenario
HRESULT RunScenario(__in CONFIGURATION_PARAMETERS* configParams)
{
//common declarations
UINT status = ERROR_SUCCESS;
HRESULT hr = S_OK;
UINT pinLen = Pin_Length_8;
//pin needs to be a null terminated ascii char[] for the IWCNDevice::SetPassword function
char pin[Pin_Length_8 + 1] = {0};
int result = 0;
//WCN declarations
CComPtr<IWCNDevice> pDevice;
CComObject<WcnConnectNotification>* pWcnConNotif = NULL;
CComObject<CWcnFdDiscoveryNotify> * wcnFdDiscoveryNotify = NULL;
//Wlan variable declarations
WCHAR profileBuffer[WCN_API_MAX_BUFFER_SIZE] = {0};
HANDLE wlanHandle = 0;
DWORD negVersion = 0;
GUID interfaceGuid = {0};
WLAN_INTERFACE_INFO_LIST* pInterfaceList = 0;
DWORD wlanResult = 0;
WLAN_CONNECTION_PARAMETERS connParams;
ZeroMemory(&connParams,sizeof(connParams));
WCN_DEVICE_INFO_PARAMETERS WCNDeviceInformation;
PWSTR pWlanProfileXml = NULL;
DWORD dwFlags = WLAN_PROFILE_GET_PLAINTEXT_KEY;
//The following wlan profile xml is used to configure an unconfigured WCN enabled Router or device.
//See http://msdn.microsoft.com/en-us/library/bb525370(VS.85).aspx on how to generate a wlan profile.
//Alternatively, you can read an existing network profile by calling WlanGetProfile.
WCHAR WCNConnectionProfileTemplate[] =
L"<?xml version=\"1.0\" ?>"
L""
L"<WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\">"
L" <name>%s</name>"
L""
L" <SSIDConfig>"
L" <SSID>"
L" <name>%s</name>"
L" </SSID>"
L" </SSIDConfig>"
L" "
L" <connectionType>ESS</connectionType>"
L" <connectionMode>auto</connectionMode>"
L""
L" <MSM>"
L" <security>"
L" <authEncryption>"
L" <authentication>WPA2PSK</authentication>"
L" <encryption>AES</encryption>"
L" </authEncryption>"
L""
L""
L" <sharedKey>"
L" <keyType>passPhrase</keyType>"
L" <protected>false</protected>"
L" <keyMaterial>%s</keyMaterial>"
L" </sharedKey>"
L""
L" </security>"
L" </MSM>"
L"</WLANProfile>";
std::wstring profileXML;
//open a wlan handle - this will be used later for saving the profile to the system
status = WlanOpenHandle(
WLAN_API_VERSION_2_0,
NULL,
&negVersion,
&wlanHandle);
if (status != ERROR_SUCCESS)
{
wprintf(L"\nERROR: WlanOpenHandle failed with the following error code [%d]", status);
hr = S_FALSE;
goto cleanup;
}
// Get the first wlan device
// ideally you would want to be able to choose the wireless device you want to use
status = WlanEnumInterfaces(
wlanHandle,
NULL,
&pInterfaceList);
if(status != ERROR_SUCCESS)
{
wprintf(L"\nERROR: WlanEnumInterfaces failed with the following error code [0x%d]",status);
hr = S_FALSE;
goto cleanup;
}
//Make sure there is at least one wlan interface on the system
//.........这里部分代码省略.........
示例15: wprintf
void CBase::Foo()
{
wprintf(L"CBase::Foo\n");
}