是否可以生成一个字节数组,然后让Windows像普通代码一样执行它?假设我们有一些汇编代码:
inc ecx
Run Code Online (Sandbox Code Playgroud)
这是一个计划的一部分.在我们用Nasm编译之后,我们得到一个EXE,其中上面的行被转换成这样的东西:
00000035 41
Run Code Online (Sandbox Code Playgroud)
是否可以创建一个字节数组,用上面的字节填充它并执行 - 所以增量实际发生了?
我已经制作了超级简单的解释语言,但由于它被解释得很慢.我不想为它编写真正的编译器,但我想让它更快 - 编译并在运行中运行.
我使用我的应用程序时出现此错误:
05-01 14:18:41.000: E/AndroidRuntime(26607): FATAL EXCEPTION: main
05-01 14:18:41.000: E/AndroidRuntime(26607): java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
Run Code Online (Sandbox Code Playgroud)
问题的方法:
public void onItemClick(AdapterView<?> adapterView, View view, int postion,
long index) {
// Get MAC adress matching the last 17 characters of the TextView
String info = ((TextView) view).getText().toString(); // HERE IS THE ISSUE
String address = info.substring(info.length() - 17);
Intent intent = new Intent();
intent.putExtra(EXTRA_DEVICE_ADDRESS, address);
setResult(Activity.RESULT_OK, intent);
BluetoothDevice device = (BluetoothDevice) view.getTag();
showEquipementActivity(device);
}
Run Code Online (Sandbox Code Playgroud)
和XML文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" …
Run Code Online (Sandbox Code Playgroud) 我想知道调用打印"double in derived"的方法的原因是什么.我没有在C#规范中找到任何线索.
public class A
{
public virtual void Print(int x)
{
Console.WriteLine("int in base");
}
}
public class B : A
{
public override void Print(int x)
{
Console.WriteLine("int in derived");
}
public void Print(double x)
{
Console.WriteLine("double in derived");
}
}
B bb = new B();
bb.Print(2);
Run Code Online (Sandbox Code Playgroud) 我是c ++的新手,我在visual studio c ++中运行以下代码
struct bob
{
double a,b;
bob(double a,double b);
}
int main()
{
bob z(2.2,5.6);
cout<<z.a<<endl;
keep_window_open();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,我收到以下错误:
错误1错误LNK2019:函数_main C:\ drives\Comp-Mech\programming\VS中引用了未解析的外部符号"public:__thiscall bob :: bob(double,double)"(?? 0bob @@ QAE @NN @ Z)\C++\projects\E1\E1.obj E1
我试图将位图保存到文件,然后将其保存在SD卡上.这是我的代码:
String path = Environment.getExternalStorageDirectory().toString();
File file = new File(path, "Jhs"+".jpg");
file.mkdir();
OutputStream fOut;
try {
fOut = new FileOutputStream(file);
BitmapMatrix convMatrix = new BitmapMatrix(0);
convMatrix.result.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
fOut.flush();
fOut.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
此代码也在一个不扩展Activity的类中.我只是给出了这个信息,认为可能存在一些问题.这是我的LogCat
05-01 18:00:22.555: W/System.err(31392): java.io.FileNotFoundException: /mnt/sdcard/Jhs.jpg (Permission denied)
05-01 18:00:22.555: W/System.err(31392): at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
05-01 18:00:22.555: W/System.err(31392): at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
05-01 18:00:22.555: W/System.err(31392): at java.io.FileOutputStream.<init>(FileOutputStream.java:94)
05-01 18:00:22.555: W/System.err(31392): …
Run Code Online (Sandbox Code Playgroud) 从PowerShell获取注册表项中的值的方法是:
Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion CommonFilesDir
Run Code Online (Sandbox Code Playgroud)
但是,该命令返回一些我通常不想要的额外属性:
CommonFilesDir : C:\Program Files\Common Files
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
PSChildName : CurrentVersion
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
Run Code Online (Sandbox Code Playgroud)
我只想要实际值,在这种情况下是一个字符串.要做到这一点,我必须使用更详细:
$commonFilesDir = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion CommonFilesDir).CommonFilesDir
Run Code Online (Sandbox Code Playgroud)
除了编写我自己的别名之外,有没有办法不写两次属性名并获取字符串?
我可以运行以下命令,但它返回一个PSObject:
Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion | Select CommonFilesDir
Run Code Online (Sandbox Code Playgroud) 我正在创建一个屏幕共享应用程序,它可以像Google Hangout Screen Shares一样工作,我想知道Google Talk插件(用于屏幕共享)如何产生子进程并使用动态端口范围.
我正在创建一个后台运行的应用程序,用户必须安装该应用程序,并与浏览器进行如下所述的对话,http://www.codeproject.com/Articles/36517/Communicating-from-the-Browser-to-a -桌面,应用程
但是,当我查看googleTalkPlugin,它负责谷歌聚会屏幕共享时,我看到有很多进程正在运行,每当我打开一个新浏览器时,该浏览器的新通话插件就会作为子服务启动.
这是一些快照
当我注意到googleTalkPlugin使用的端口时,我开始了解它的动态!如果您看到上面的链接,则浏览器桌面通信位于静态端口上.
我很有兴趣知道,我如何使用动态端口号?另外,我应该为每个浏览器创建子进程吗?还是更好的东西?
我有这样的XML:
<SPPROFILES>
<----DATA------>
<PROFILES>
<PROFILE>
<ID>--------------</ID>
<NAME>------------</NAME>
<USERNAME>-----------</USERNAME>
</PROFILE>
</PROFILES>
</SPPROFILES>
Run Code Online (Sandbox Code Playgroud)
我想从XML获取用户名并显示它.
这是代码的一部分:
SFailedHMConnection = 'Could not connect to default database with username "-------".';
Run Code Online (Sandbox Code Playgroud)
用户名后面的"------"应该显示XML中的用户名,那么如何从XML中获取值并将其包含在消息中呢?
如何做Scala相当于这个Java代码:
int i = 0;
for(String x: xs) {
for(String y : ys) {
foo(x, y, i);
i+=10;
}
}
Run Code Online (Sandbox Code Playgroud) 如果我有两个已经在兼容键上排序的数据帧(或系列),我希望能够便宜地将它们合并在一起并保持排序.除了通过concat()和显式sort()之外,我看不到这样做的方法
a = pd.DataFrame([0,1,2,3], index=[1,2,3,5], columns=['x'])
b = pd.DataFrame([4,5,6,7], index=[0,1,4,6], columns=['x'])
print pd.concat([a,b])
print pd.concat([a,b]).sort()
x
1 0
2 1
3 2
5 3
0 4
1 5
4 6
6 7
x
0 4
1 0
1 5
2 1
3 2
4 6
5 3
6 7
Run Code Online (Sandbox Code Playgroud)
看起来有一些关于numpy数组的相关讨论,暗示了一种"交错"方法,但我没有找到一个好的答案.
android ×2
delphi ×2
assembly ×1
bitmap ×1
c ×1
c# ×1
c++ ×1
compilation ×1
constructor ×1
file ×1
for-loop ×1
hangout ×1
inheritance ×1
interpreter ×1
networking ×1
numpy ×1
overloading ×1
pandas ×1
powershell ×1
python ×1
registry ×1
scala ×1
sd-card ×1
struct ×1
textview ×1
winapi ×1
xml ×1