|
Thanks Holguin....
I install Dev-C++ i think is the best IDE for me.
Thanks all for yours answers.
|
|
|
|
|
Hi,
I'm using windows 7 pc, and trying to write a Bluetooth server app.
My requirement is to pair my Mobile (Nokia -N8) with my server app, and then exchange data using a service class.
ISSUE:
The issue I'm facing is, on running server on my PC, the server waits for connection request from phone.
But phone is asking me to enter a pass code, But i don't know how to handle this passcode issue at server side. and establish the connection.
The connection always fails with a message that no response from server.
Here is my server code, which I'm running on my win 7 PC.
// Bluetooth.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <winsock2.h>
#include <ws2bth.h>
#include <bthsdpdef.h>
#include <bluetoothapis.h>
#pragma comment(lib, "Ws2_32.lib")
int _tmain(int argc, _TCHAR* argv[])
{
//----------------------
// Initialize Winsock.
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != NO_ERROR)
{
wprintf(L"WSAStartup failed with error: %ld\n", iResult);
return 1;
}
//----------------------
// Create a SOCKET for listening for
// incoming connection requests.
SOCKET ListenSocket;
ListenSocket = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM);
if (ListenSocket == INVALID_SOCKET) {
wprintf(L"socket failed with error: %ld\n", WSAGetLastError());
WSACleanup();
return 1;
}
//----------------------
// The sockaddr_in structure specifies the address family,
// IP address, and port for the socket that is being bound.
SOCKADDR_BTH blthsocket;
memset(&blthsocket,0,sizeof(SOCKADDR_BTH));
blthsocket.addressFamily = AF_BTH;
blthsocket.btAddr = 0;
blthsocket.serviceClassId = GUID_NULL;
blthsocket.port = BT_PORT_ANY ;
wprintf(L"============ Before Bind =============\n");
wprintf(L"blthsocket.btAddr = %d \n",blthsocket.btAddr);
wprintf(L"blthsocket.port = %d \n",blthsocket.port);
if (bind(ListenSocket,(SOCKADDR *) & blthsocket, sizeof (blthsocket)) == SOCKET_ERROR)
{
wprintf(L"bind failed with error: %ld\n", WSAGetLastError());
closesocket(ListenSocket);
WSACleanup();
return 1;
}
wprintf(L"Binding is complete\n");
wprintf(L"\n\n============ After Bind =============\n");
int len = sizeof(blthsocket);
if (0 == getsockname (ListenSocket, (sockaddr*)&blthsocket, &len))
{
wprintf (L"Local Bluetooth device is %04x%08x \nServer channel = %d\n",
GET_NAP(blthsocket.btAddr), GET_SAP(blthsocket.btAddr), blthsocket.port);
}
//----------------------------------------------------------------------------
wprintf(L"Waiting for client to connect...\n");
listen (ListenSocket, 5);
for ( ; ; ) {
SOCKADDR_BTH sab2;
int ilen = sizeof(sab2);
SOCKET s2 = accept (ListenSocket,(sockaddr*)&sab2, &ilen);
if (s2 == INVALID_SOCKET) {
wprintf (L"Socket bind, error %d\n", WSAGetLastError ());
break;
}
wprintf (L"Connection came from %04x%08x to channel %d\n",
GET_NAP(sab2.btAddr), GET_SAP(sab2.btAddr), sab2.port);
wprintf (L"Hello");
SpinConnectionThreadsOnSocket (s2);
}
closesocket (ListenSocket);
WSACleanup();
return 0;
}
Kindly help resolving this issue, Thanks in advance.
Regards,
Vijay.
|
|
|
|
|
Windows has several bluetooth APIs that you can use.
BluetoothAuthenticateDevice is the API to send authentication code to the bluetooth device.
|
|
|
|
|
I have written an MFC application, with an embedded WebBrowser Control, using Visual Studio 6 C++
It follows an example on MSDN entitled "Using MFC to Host a WebBrowser Control".
The application creates an html script and navigates to it using code similar to ...
m_browser.Navigate(filenamestring, NULL,NULL,NULL,NULL); for example.
If the connection fails, I get the "Internet Explorer Script Error" debug popup.
Is it possible to detect / trap this error within my program so the popup is not generated ??
modified on Monday, August 22, 2011 12:50 PM
|
|
|
|
|
Try calling SetSilent(TRUE) on the web control maybe.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
That works great, thanks.
However it exposes a new issue, how do I now know if it failed ?
I want to show a message if it fails
|
|
|
|
|
I have no idea really, sorry. Google is your friend...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
|
This article shows how to display a message box (good) but i need to detect the need for it.
If the Navigate fails (the cable is out) i get a script error box. SetSilent() prevents the error box but now i just have a blank WebBrowser2. How am i alerted of the error ??
|
|
|
|
|
If your code (for display or simply do nothing) get called, then you are detected for it.
|
|
|
|
|
Hi,
I'm trying to disable the 'Alt' key. There's a Windows' Scan Code Mapping technique which disables the keys. I'm writing the required registry entries from my Win32 application. This successfully disables the key from my physical keyboard. But this technique doesn't disable the keys from On-Screen Keyboard. When I spy the On-Screen keyboard, I found only one control on it. Is there any way or API to disable the keys from On-Screen keyboard ?
Thanks in advance.
|
|
|
|
|
Are you trying to disable the Alt key system-wide, or just for your app?
|
|
|
|
|
|
|
You might try to disable it via a service.
On a side note, disabling a key is a very strange requirement: Are you sure it is the solution to your problem ?
|
|
|
|
|
You might try to disable it via a service.
via service? why should I need a service. And if at all, how can I do that?
On a side note, disabling a key is a very strange requirement: Are you sure it is the solution to your problem ?
Yes.
|
|
|
|
|
Hi,
I am designing a small utility to scan hard drive for specific file types.
But I am facing strange problem in it.
A dialog box is scanning the drive, When I press "Cancel" button to stop the process, it opens window dialog box to ask for shutdown the windows.
But I am just doing CDialog::OnOk() on button click;
This is happening with windows7 only, on XP it is running fine.
Please guide.
|
|
|
|
|
john5632 wrote: Please guide.
Please show the code path taken when you press "Cancel".
|
|
|
|
|
if(MessageBox(_T("Do you want to cancel recovery?"),_T("Information"),MB_YESNO|MB_ICONQUESTION)==IDYES)
{
g_bStopScanning=TRUE;
CDialog::OnOK();
}
|
|
|
|
|
There must be more to this than meets the eye. I suggest you track this through your debugger.
|
|
|
|
|
I don't see how this could cause the problem you described, but shouldn't you be calling CDialog::OnCancel() ?
|
|
|
|
|
Is the scanning going on in a secondary thread?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi,
I have property sheet with PSH_HASHELP button.
But how to create handler of this button?
|
|
|
|
|
Add a function to the class to handle the help button click - void OnPropertyBtnHelp(void);
Then add the following to the message map - ON_COMMAND(IDHELP, OnPropertyBtnHelp)
To handle the F1 key press create a handler for WM_HELPINFO .
|
|
|
|
|
I have read the MSDN document section about Journal Hook over and over again, still be confused with the following things.
1.Does the Journal Record Hook record the user actions( like mouse clicks or keyboard events ), then Journal Playback Hook replays the series of actions which the user has just performed?
2.The lParam of the JournalRecordProc is a pointer to a EVENTMSG, I can copy it to a buffer as the MSDN tells us to, but what are we supposed to do with these EVENTMSG buffer?
3.The lParam of the JournalPlaybackProc is also a pointer to a EVENTMSG, I think this EVENTMSG is one of the actions which the user has just performed, what should we do with it in order to replay the action?
|
|
|
|