identification

How to generate an unique computer id on Delphi?

走远了吗. 提交于 2019-11-27 05:48:34
问题 How can I quickly generate an unique computer id for a delphi app? I used to do it easly with c#, but this failed sometimes. I do want the ID to be "static" but I don't care if the id changes because of a hardware change or OS reinstallation, I was planning to store it in the registry and check it when the app starts, and if it changed update the registry. (I know how to code the registry part, I only need help for the unique id). Thanks. 回答1: Use the hard disk serial number or MAC address:

How do I check if an object's type is a particular subclass in C++?

拟墨画扇 提交于 2019-11-27 03:48:29
I was thinking along the lines of using typeid() but I don't know how to ask if that type is a subclass of another class (which, by the way, is abstract) You really shouldn't. If your program needs to know what class an object is, that usually indicates a design flaw. See if you can get the behavior you want using virtual functions. Also, more information about what you are trying to do would help. I am assuming you have a situation like this: class Base; class A : public Base {...}; class B : public Base {...}; void foo(Base *p) { if(/* p is A */) /* do X */ else /* do Y */ } If this is what

How to check if a file is a valid image file?

核能气质少年 提交于 2019-11-26 18:39:53
I am currently using PIL. from PIL import Image try: im=Image.open(filename) # do stuff except IOError: # filename not an image file However, while this sufficiently covers most cases, some image files like, xcf, svg and psd are not being detected. Psd files throws an OverflowError exception. Is there someway I could include them as well? A lot of times the first couple chars will be a magic number for various file formats. You could check for this in addition to your exception checking above. I have just found the builtin imghdr module. From python documentation: The imghdr module determines

How do I check if an object's type is a particular subclass in C++?

大城市里の小女人 提交于 2019-11-26 10:39:37
问题 I was thinking along the lines of using typeid() but I don\'t know how to ask if that type is a subclass of another class (which, by the way, is abstract) 回答1: You really shouldn't. If your program needs to know what class an object is, that usually indicates a design flaw. See if you can get the behavior you want using virtual functions. Also, more information about what you are trying to do would help. I am assuming you have a situation like this: class Base; class A : public Base {...};

How to check type of files without extensions in python?

不打扰是莪最后的温柔 提交于 2019-11-26 07:17:24
I have a folder full of files and these doesn't have an extension. How can I check file types? I want to check the file type and change the filename accordingly. Let's assume a function filetype(x) returns file type like png . I want to do this: files = os.listdir(".") for f in files: os.rename(f, f+filetype(f)) How do I do this? There are Python libraries that can recognize files based on their content (usually a header / magic number) and that don't rely on the file name or extension. If you're addressing many different file types, you can use python-magic . That's just a Python binding for

How to check type of files without extensions in python?

我与影子孤独终老i 提交于 2019-11-26 01:07:03
问题 I have a folder full of files and they don\'t have an extension. How can I check file types? I want to check the file type and change the filename accordingly. Let\'s assume a function filetype(x) returns a file type like png . I want to do this: files = os.listdir(\".\") for f in files: os.rename(f, f+filetype(f)) How do I do this? 回答1: There are Python libraries that can recognize files based on their content (usually a header / magic number) and that don't rely on the file name or