在xp下编译后,在win7中运行,可以设置但连接时总提示密码不对。
之前用delphi7在win7下编译运行通过,并用手机的wifi连接上了。怎么回事啊。

解决方案 »

  1.   


    //AName:无线AP名称,不超过32个字符
    //APass:密码,至少8个字符
    //function SetSoftAP(AName, APass: string): Boolean;
    //var
    //  phClient: THandle;
    //  dwVer, dwRet: DWORD;
    //  pwhnr: WLAN_HOSTED_NETWORK_REASON;
    //  pwhnc: WLAN_HOSTED_NETWORK_CONNECTION_SETTINGS;
    //  pTemp: PAnsiChar;
    //  pb: BOOL;
    //begin
    //  Result := False;
    //  dwRet := WlanOpenHandle(1, nil, @dwVer, @phClient);
    //  if dwRet <> ERROR_SUCCESS then
    //    Exit;
    //
    //  dwRet := WlanHostedNetworkInitSettings(phClient, @pwhnr, nil);
    //  if dwRet = ERROR_SUCCESS then
    //  begin
    //    pTemp := PAnsiChar(AnsiString(AName));
    //    pwhnc.hostedNetworkSSID.uSSIDLength := lstrlenA(pTemp);
    //    ZeroMemory(@pwhnc.hostedNetworkSSID.ucSSID, 32);
    //    CopyMemory(@pwhnc.hostedNetworkSSID.ucSSID, pTemp, lstrlenA(pTemp));
    //    pwhnc.dwMaxNumberOfPeers := 10;
    //    //设置无线AP的名称
    //    dwRet := WlanHostedNetworkSetProperty(phClient,
    //      wlan_hosted_network_opcode_connection_settings,
    //      SizeOf(pwhnc), @pwhnc, @pwhnr, nil);
    //    if dwRet = ERROR_SUCCESS then
    //    begin
    //      pb := True;
    //      //启用网络承载
    //      dwRet := WlanHostedNetworkSetProperty(phClient,
    //        wlan_hosted_network_opcode_enable, SizeOf(pb), @pb, @pwhnr, nil);
    //      Form1.mmo1.Lines.Add(IntToStr(dwRet) + ': 2');
    //      if dwRet = ERROR_SUCCESS then
    //      begin
    //        pTemp := PAnsiChar(AnsiString(APass));
    //        //设置无线AP的密码
    //        dwRet := WlanHostedNetworkSetSecondaryKey(phClient, lstrlenA(pTemp) + 1,
    //          PUCHAR(pTemp), True, False, @pwhnr, nil);
    //        Form1.mmo1.Lines.Add(IntToStr(dwRet) + ': 3');
    //        if dwRet = ERROR_SUCCESS then
    //        begin
    //          //开启无线AP
    //          dwRet := WlanHostedNetworkStartUsing(phClient, @pwhnr, nil);
    //          Result := dwRet = ERROR_SUCCESS;
    //        end;
    //      end;
    //    end;
    //  end;
    //  WlanCloseHandle(phClient, nil);
    //end;
      

  2.   

    wlanapi声明部分
    http://download.csdn.net/detail/lght/3795678
      

  3.   

    AName, APass: string类型改成宽字符试试
    var AName, APass: PWideChar;