soknaly

Create Hotspot Using C

Mar 11th, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.40 KB | None | 0 0
  1. #‎include‬<stdio.h>
  2. #include<string.h>
  3. #include<conio.h>
  4. #include<stdlib.h>
  5. int status;
  6. void createHotspot(){
  7. char ssid[32],key[32],command[100];
  8. SSID:
  9. clrscr();
  10. printf("SSID: ");
  11. gets(ssid);
  12. if(strlen(ssid)<8){
  13. printf("\nSSID must be more than 8 digits.");
  14. getch();
  15. goto SSID;
  16. }else{
  17. KEY:
  18. printf("Key: ");
  19. gets(key);
  20. if(strlen(key)<8){
  21. printf("\nKey must be more than 8 digits.");
  22. getch();
  23. clrscr();
  24. printf("SSID: %s\n",ssid);
  25. goto KEY;
  26. }else{
  27. strcpy(command,"netsh wlan set hostednetwork mode=allow ssid=");
  28. strcat(command,ssid);
  29. strcat(command," key=");
  30. strcat(command,key);
  31. status=1;
  32. system(command);
  33. }
  34. }
  35. }
  36. void startHotspot(){
  37. if(status==1){
  38. system("netsh wlan start hostednetwork");
  39. status=2;
  40. }else if(status==0){
  41. printf("\n\nHotspot hasn't been created yet. Please create Hotspot first!");
  42. }
  43. }
  44. void stopHotspot(){
  45. if(status==2){
  46. system("netsh wlan stop hostednetwork");
  47. status=3;
  48. }else if(status==1){
  49. printf("\nHotspot hasn't started yet.");
  50. }else if(status==0){
  51. printf("Please create Hotspot first!");
  52. }
  53. }
  54. void resetHotspot(){
  55. }
  56. void main(){
  57. do{
  58. clrscr();
  59. printf("1.Create Virtual Hotspot\n");
  60. printf("2.Start Virtual Hotspot\n");
  61. printf("3.Stop Virtual Hotspot\n");
  62. printf("4.Exit\n");
  63. switch(getch()){
  64. case '1':createHotspot();break;
  65. case '2':startHotspot();break;
  66. case '3':stopHotspot();break;
  67. }
  68. }while(getch()!='4');
  69. system("attrib config.ini +s +h");
  70. }
Advertisement
Add Comment
Please, Sign In to add comment