2014-11-04 137 views
0

我想获取客户端计算机mac地址,以便用户无法从其他计算机登录。我是PPAPI的新手,并尝试使用C语言中的代码来获取mac地址。它需要PPAPI lib不包含的conio.h头文件。我也在外部添加了这个文件,但没有帮助。任何想法如何使用PPAPI插件或PNACL获取客户端计算机mac地址

{ 
/* Copyright (c) 2013 The Chromium Authors. All rights reserved. 
* Use of this source code is governed by a BSD-style license that can be 
* found in the LICENSE file. 
*/ 

#include <stdio.h> 
#include <string.h> 
#include <stdlib.h> 

#include "ppapi_simple/ps_main.h" 

#ifdef SEL_LDR 
#define example_main main 
#endif 

int example_main(int argc, char* argv[]) { 
    /* Use ppb_messaging to send "Hello World" to JavaScript. */ 
    FILE *fp; 
    printf("Hello before system.\n"); 
    system ("ipconfig/all>D://macid.txt"); 
printf("Hello before file open.\n"); 
fp=fopen("D://macid.txt","r"); 
printf("Hello before if.\n"); 
if(fp!=NULL) 
    { 
     printf("Hello before while.\n"); 
     char line[128]; 
     while(fgets(line,sizeof line,fp)!=NULL) 
     { 
      printf("Hello in while.\n"); 
      char *nwln=strchr(line,'\n'); 
      char *ptr; 
      if(nwln!=NULL) 
      *nwln='\0'; 
      ptr=strstr(line,"Physical Address"); 
      if(ptr!=NULL) 
      { 
       printf("Hello in iff.\n"); 
       printf("hello : %s\n",ptr); 
       break; 
      } 
     } 
    } 

printf("Hello World STDOUTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT.\n"); 
printf("Hello Deepesh Jain.\n"); 

/* Use ppb_console send "Hello World" to the JavaScript Console. */ 
fprintf(stderr, "Hello World STDERR.\n"); 
return 0; 
} 

/* 
* Register the function to call once the Instance Object is initialized. 
* see: pappi_simple/ps_main.h 
* 
* This is not needed when building the sel_ldr version of this example 
* which does not link against ppapi_simple. 
*/ 
#ifndef SEL_LDR 
PPAPI_SIMPLE_REGISTER_MAIN(example_main) 
#endif 

} 

回答

1

你想要做一个Web应用程序,或扩展?一般来说,PPAPI和NaCl不会提供比传统网络平台更多的API,所以如果您要使用网络应用程序,则无法访问MAC地址。在扩展中,您可能有权访问更多API,例如最近添加的主机名。

网络平台确实有其他机制来识别用户,如cookie,但这些机制由用户控制并可能被驱逐。

+0

我想为Web应用程序执行此操作。因为Web应用程序不允许获取客户端计算机MAC地址,这就是为什么我要制作一个插件,每次加载登录页面时都会调用该插件。 – 2014-11-05 07:06:37

相关问题