首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用PPAPI插件或PNACL获取客户机mac地址

如何使用PPAPI插件或PNACL获取客户机mac地址
EN

Stack Overflow用户
提问于 2014-11-04 22:12:00
回答 1查看 615关注 0票数 0

我想获得客户端机器的mac地址,这样用户就不能从其他计算机登录。我是PPAPI的新手,我尝试过用C语言编写下面的代码来获取mac地址。它需要PPAPI lib不包含conio.h头文件。我也在外部添加了这个文件,但没有帮助。有什么想法吗?

代码语言:javascript
复制
{
/* 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

}
EN

回答 1

Stack Overflow用户

发布于 2014-11-05 00:50:30

你是想为一个web应用程序这么做,还是为了一个扩展?一般来说,PPAPI和NaCl不会提供比传统网络平台更多的API,所以如果你想要一个网络应用,那么你就不能访问MAC地址。在一个扩展中,你可以访问更多的API,比如最近添加的主机名。

web平台确实有其他机制来识别用户,例如cookies,但这些机制在用户的控制下,可能会被驱逐。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26737263

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档