Home » Visual Studio

BluetoothEnableDiscovery and BluetoothEnableIncomingConnections Questions under win7

hi,  the API(BluetoothEnableDiscovery and BluetoothEnableIncomingConnections) calls work successfully when I set Discoverability unchecked via the BT Setting cpl.

But once i set the Discoverability checked via the BT Setting cpl, from then on the API(BluetoothEnableDiscovery) calls work failed no matter you BluetoothEnableDiscovery(hRadio,TRUE) or BluetoothEnableDiscovery(hRadio,FALSE), also the API (BluetoothEnableIncomingConnections) failed.

And is there anyone  can help me? tell me how I can use API(BluetoothEnableDiscovery) to control the Bluetooth's Discovery Enable or Disable?!


1 Answer Found


Answer 1

Or win7  SP1 will reslove this issue???????

I have existing code that has worked under Vista fine, but under Win 7 RC it fails.

On a fresh box both BluetoothEnableDiscovery() and BluetoothEnableIncomingConnections() will fail with the last error code of 80070057.

But once i set the Discoverability or Allow Incoming connections via the BT Setting cpl, from then on the API calls work successfuly.

I've also tried the variant w/ passing null instead of the radio handle.
DWORD EnableDiscovery(ULONGLONG btAddr ,BOOL bEnabled)
   HANDLE hRadio;
   BLUETOOTH_FIND_RADIO_PARAMS btfrp = { sizeof(btfrp) };

   HBLUETOOTH_RADIO_FIND hFind = BluetoothFindFirstRadio( &btfrp, &hRadio );
   if ( NULL != hFind )

		   if (dwRes == ERROR_SUCCESS)
            if ( btAddr == btri.address.ullLong)
               BOOL z=BluetoothEnableDiscovery(hRadio,bEnabled);
                  TCHAR c[600];
                  wsprintf(c, _T("Error enabling discoverability:%X\r\n"), GetLastError());
               CloseHandle( hRadio );

            CloseHandle( hRadio );
      } while( BluetoothFindNextRadio( hFind, &hRadio ) );

      BluetoothFindRadioClose( hFind );

   return dwRes;


I currently try to find out the CPU frequency of my desktop computer using QueryPerformanceFrequency() in Visual Studio 2008.  It returns the frequency to be 2597666 which doesn't match my CPU frequency. The desktop I have is running on Win 7 Home Edition, the processor is Intel Core 2 Quad CPU Q8400 @ 2.66GHz 2.67GHz, Installed memory is 8.00GB.

I have already try the code on another desktop computer with Win XP and dual core, and the frequency came out to be correct.

Can anyone tell me what the problem is?



I have a problem setting up the title for a dialog after it has been initialized.

CString title = _T("New Title");

if( GetSafeHwnd() )


CString str;


// str here IS "New Title" ... so it's ok, but it doesn't show in the dialog's title !

On my PC, running Windows 7, the Dialog title remains empty in both debug & release. The same is true for a different machine also running Windows 7.

BUT, on an XP machine it's fine, the title does change.

Does anyone have any suggestions ?

Thanks !!




I've developed a Windows Forms application in .NET 3.5, VS 2008, WinXP. I've used a DataGridView control in the form. When i run the application in Windows XP the grid is displayed properly but the same application if i am running it in Windows 7, the grid is displayed in black color.


For textBox border color also it acts in funny manner.

My textbox and datagridview properties are as follows:

1. textboxTop.BackColor =  LightSteelBlue;

2. DataGridViewData.BackgroundColor = InactiveCaptionText;


Windows XP: nice and smooth and according as the property set

Wndows 7 : textbox border changed, groupBox border changed, Datagridview BackgroundColor changed to black (weird)


Sample preview links:

WinXP : http://yfrog.com/muwinxpj

Win7 : http://yfrog.com/16win7qj


>> Is this a bug of visual studio? or did I miss anything to set. Please help me how to fix the issue.



Hi ,

     Recently am facing one problem while connecting to VSS(network machine). When I run SSEXP.exe in run as administrator then am encountered "Invalid Error" message. But when I run SSEXP.exe in normal mode(just double click) then am getting user name and password Dialog (once i enter my user name and password then i could able to connect VSS). I checked my network connections it's fine and manually mapped server to my system. Can anyone reply me how to resolve this problem?? 



previously i had an XP Pro 32-bit OS & vs2005. which i had the following installed.

Guidance Automation Extensions
Guidance Automation Toolkit
Data Access Guidance Package

now we have moved to Windows 7 64-bit Enterprise edition with vs2008 SP1 Pro Edition

i have found the correct GAX & GAT installs from the following link

but i am unsure if these are suitable for Win7 and also where to find the correct Data Access Guidance Package for 2008

Any help is greatly appreciated.


how do I build a windows application around a excel spreadsheet in 64bin win7

Recently I installed VS2010 professional in Win7.

I want to learn the win32 socket programing following the guide: http://msdn.microsoft.com/en-us/library/ms738566%28v=VS.85%29.aspx

However, I create a c++ empty project in VS2010, copy the code into a cpp file, compile it well , but link errors as follows:

1>socket-server.obj : error LNK2019: unresolved external symbol __imp__freeaddrinfo@4 referenced in function _main
1>socket-server.obj : error LNK2019: unresolved external symbol __imp__WSAGetLastError@0 referenced in function _main
1>socket-server.obj : error LNK2019: unresolved external symbol __imp__socket@12 referenced in function _main
1>socket-server.obj : error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function _main
1>socket-server.obj : error LNK2019: unresolved external symbol __imp__getaddrinfo@16 referenced in function _main
1>socket-server.obj : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function _main
1>C:\Users\chuanxu\Documents\Visual Studio 2010\Projects\prototype_staf\Debug\prototype_staf.exe : fatal error LNK1120: 6 unresolved externals


Any suggestion about it?




We have code in our former VB6 application, that ported fine to VB.NET, that plays a simple AVI file of the typical "flying folders" and "spinning maginfying glass" AVI.  Under Windows XP, our application ran fine and everything was good...

Then we had customers start using Vista and Win7 and this stuff crashes.  We were using the MS Common Controls (SP4) and then (SP6) - utilizing the Animation player.  Now - these dont work and we get nasty errors.

I searched Microsoft and the web to answer the "what now?" question and though there are numerous suggestions, none of them work.  We cant use Media Player because we dont want any menu - just the graphic.  We dont know why, with the cool tools given in .NET, there is no animation player (seems a huge oversight...)  But we need to get "unstuck" on this one, and we need that fast...

So, How does on play a simple AVI file using VB.NET code?  What DLL or OCX does Microsoft recommend and is there a place we can find some sample code for it?

Any help anyone can give is MOST appreciated!

I've a problem to register a dll to the gac using .net 4.0.
In fact I'm devloping a Windows Media Center plugin, follow the guide from the SDK.
If I compile my assembly with .net 3.5, I can add it into the gac, and works in WMC smoothly.
But if I compile it with target envoirment .net 4, it seems not work.
I regitered it with the gacuitl tool, which i found under folder "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools".
Other verion gacuitl tool will raise a error.
But I can't see it under "C:\Windows\assembly" (which I can see my assembly if I use .net 3.5).
And WMC report an exception: System.IO.FileNotFoundException ... (with my assembly)

I think it's the problem that assembly to well registered to the GAC.
But I don't know how to verify it anymore.
Please give me some advise.
I don't know howto verify whether the assembly is successfull added.

I faced this issue int x64 win7, but didn't notice that in 32bit win7 and winxp, is there any reasonable explaination? Anyone else encounter that problem?




Could someone tell me what system requirement do I need to use for Win7 logo ?

Version of WLK ? Is it v1.5 ?

Version of Windows 7 ? English or can I use other language ? RTM or else?

Operating system of DTM controller ?


Thanks everyone.


We have observed an unexpected change in behaviour with the WinSCard.dll API on windows7/vista.

we poll in a loop SCardGetStatusChange method to detect when a smartcard is inserted or removed (by monitoring the m_dwEventState of each card reader for the CHANGED, PRESENT and EMPTY flags)

when a card insert is detected we connect to the card using the SCardConnect method, and perform whatever operations we need to do on the card. when a card removal is detected we call SCardDisconnect method.

this all works as expected on XP, however on windows7/vista when the SCardDisconnect method is called after the card has been removed we observe an unexpected CARD_STATE.PRESENT followed CARD_STATE.EMPTY event returned from the SCardGetStatusChange method.

in summary the following steps occur:

1) we insert the card -> SCardGetStatusChange reports an event with CARD_STATE.PRESENT flag set

2) we connect to the card using SCardConnect

3) the card is removed -> SCardGetStatusChange reports an event with CARD_STATE.EMPTY flag set

4) we release our connction to the card api by calling SCardDisconnect

on XP nothing else happens, however on win7/Vista:

5) SCardGetStatusChange reports an event with CARD_STATE.PRESENT flag set

6) SCardGetStatusChange reports an event with CARD_STATE.EMPTY flag set

i.e. on windows 7 /vista we appear to see another card insert/removal when in reality nothing has happened. note these unexpected events also appear to have the CARD_STATE.MUTE flag set, the MUTE flag is not set in the observed events in steps 1 and 3.

Also notable is that this issue does not occur if Windows 7 is running in a remote desktop session and receiving smartcard input from a host pc running XP. I.e. the issue only occurs when the operating system reading the smartcard is Windows7/Vista.

We have an example project available that illustrates the behaviour if necessary.

Hi, I am facing an issue with IE8 and Windows 7. The popup is open up as

function goRelURL(){


 winObj.focus(); } 

In the popup windows I am trying to close the popup and redirecting the parent to a URL like this:



It redirects the popup to this URL and popup remians open. With WIN-XP it works fine but not with windows-7. Not sure what has changed in IE8 with Windows 7. 

I tried with "Enable Proceted Mode" but no luck. Whaty could be wrong !!!


I've read a few questions here about strange behaviors (eg mouse:hover) and references to the javascript engine in ie8 being different from earlier incarnations.

None of those clearly stated anything that would help in my (now intermittent) situation.

in IE6 this worked cleanly and consistently and still does on other IE6 workstations. But there are 2 new win7&IE8 stations that exhibit the following:

(classic asp vbscript:server, javascript:client): button "Print Receipt": click(): window.open("rptreceipt.asp",...)  the last line of executable code in rptreceipt.asp is "Window.print()"  This always kicked off the expected printing dialogue.

On the new stations the new window briefly (<1sec) appears, is removed and no dialogue appears.  Since the app believes (rightly or wrongly) the receipt was printed the app now looks like this to the user:

button "Print Receipt Again": click(): window.open("rptreceipt.asp",...)  (identical logic).  This time the user _always_ gets the expected behaviors of a window and a print dialogue.

It strikes/struck me as some sort of speed issue peculiar to IE8.  I could find no forum pops specific to window.print() or "windows closing unexpectedly".

Not knowing exactly what was wrong and after attempts at using .onafterprint() etc. (all ng) I cleaned up the code between the two .asp -- and now have the issue down to intermittent (the first "Print Receipt" now _often_ works but not 100% of the time).  Which makes me even surer(sp!) that it is some sort of speed/cpu/traffic issue.  Intermittents are the worst and taken me to the wall.

So, any insights or direction to other questions here or topics anywhere else re the possibility of inconsistent results depending on _fill in the blank_ using IE8 javascript?

Happy Friday and thanks.







In my code, I try to use Windows API:CreateWaitableTimer and SetWaitableTimer to wake up system from Standby.
It does work on Vista OS, but failed on Win 7. When the time is up, the system still in standby status.

From Google, some guys say in Win 7, should use new API:CreateWaitableTimerEx and SetWaitableTimerEx, but still not work.

Anyone have ideas about this?

Hi guys:

A filter device driver sends this irp with IOCTL_ATA_PASS_THROUGH to idle HDD head, the code works on XP SP2, but on Win7 return invalid_parameters, anybody has idea?

I find a article says IOCTL_ATA_PASS_THROUGH is obsolete on Vista, is it right?

 but the error code is not invalid control code, but invalid parameters. Could anyone help me about this, thanks!

normally, the low-level miniport driver - apapi.sys will handle this command, this driver still on Win7


I work on a shell extension for Explorer.  My extension requires being able to get the index of the item the mouse cursor is over.  On Windows 7, the only documented way to do this that I know of is through UIAutomation, as detailed here .  It works fine at first.  Unfortunately, it seems that after my extension has been running for a while, Explorer's performance begins to degrade.  The easiest way to see this is by scrolling through a directory with many files; scrolling though the list of files becomes slower and slower.  After some debugging, it seems UIAutomation is the cause.  I'm at the end of my rope here.  Either I'm doing something fundamentally wrong, or I've found a major bug in Windows Explorer.  I'm really hoping it's the former.

The problem seems to have nothing to do with shell extensions or even running in explorer.exe's process space.  Here's a simple C++ program that quickly and consistently reproduces the problem on any system I've tried:

#include <UIAnimation.h>
#include <UIAutomationClient.h>
#include <iostream>

int main() {
  IUIAutomation* pAutomation = NULL;
  CoCreateInstance(__uuidof(CUIAutomation), NULL,
    CLSCTX_INPROC_SERVER, __uuidof(IUIAutomation), (void**)&pAutomation);

  int count = 0;
  while(true) {
    if((GetKeyState(VK_SHIFT) & 0x8000) == 0) continue;

    POINT pt;
    for(int i = 0; i < 100; ++i) {
      IUIAutomationElement* elem;
      pAutomation->ElementFromPoint(pt, &elem);
    std::cout << count << " queries.\n";

  return 0;

This program runs in a loop, and whenever the shift key is down, it queries the automation element beneath the cursor and immediately releases it.  Once this program is running, I load up an Explorer window to a folder with many files, such as C:\Windows\system32.  Dragging the scroller up and down is very smooth, as it should be.  Then I hold down shift for a while with the mouse cursor in the ItemsView.  After about 2000 queries, dragging the scroller up and down is somewhat laggy.  After 5000 queries, the effect is very noticeable.  After 10000 queries, dragging the scroller up and down updates the window less than once per second.  I want to stress that I'm scrolling with the shift key up, so no queries are being executed while I'm scrolling.

More alarming is that this effect is cumulative!  If I do 10000 queries on the ItemsView and then close and reopen the Explorer window or navigate to a new folder (which destroys and recreates the ItemsView component), scrolling becomes quick and responsive again.  However, as soon as I execute a single UIAutomation query on the new ItemsView, it slows down again as if I'd done 10000 queries on that ItemsView!  The only way I've found to "reset the count" is to restart explorer.exe via the Task Manager.

Using the above code, I've been able to reproduce this on every machine I've tried it on, x86 and x64.  So, is there something wrong with my code above?  Am I suppose to release something that I'm not?  Or is this a bug in Explorer?  Is there anything at all I can do?


Hi Everyone, I am having a painting issue with Contextual Tab groups on the Ribbon. This issue does not occur if Aero Glass is enabled. In the process of developing my application, I have a slider which allows me to adjust the hue of the ribbon. If a contextual tab group is available, the hue also adjusts to keep the tab group differentiated from the color of the ribbon. The thin colored line changes as the hue changes, but the tab group header in the non client area is not repainted. Forcing a repaint of the non-client area by way of resizing the window seems to resolve this issue.

My Question: Does anyone else have a workaround for this issue or has anyone else experienced this problem. I was thinking of allowing customers the option to change the color of their ribbons at runtime, but with an issue like this, that will not be possible.

Thanks, Trevor

Under Win7, when in Aero theme, after calling IUIFramework::Destroy() the top (title bar) of the frame window is not restored.
The top rectangle space of the title bar is blurred and ::DwmExtendFrameIntoClientArea () with 0 sized margins does not change anything. ::GetClientRect() returns a top coord of 0, DefWindowProc() with WM_NCCALCSIZE does the same.

This does not happen with updated Vista and when Aero is disabled in Win7.

Is it a Win7 bug, as it does not happen in updated Vista, or some kind of undocumented feature?

If so what steps should I follow to restore the unRibbonned window?


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure