问题列表 - 第23591页

C#listview添加项目

问候,

我有一种捕获数据包的方法.捕获后我想实时添加每个数据包作为listview中的一行,所以一旦我捕获数据包,我想将它添加到列表视图中.

我使用items.Add()的问题我将得到重载参数错误.请指教!!

这是我的代码:

private void packetCapturingThreadMethod(){

        Packet packet = null;
       int countOfPacketCaptures = 0;
        while ((packet = device.GetNextPacket()) != null)
            {

            packet = device.GetNextPacket();
            if (packet is TCPPacket)
                {
                TCPPacket tcp = (TCPPacket)packet;
                myPacket tempPacket = new myPacket();

                tempPacket.packetType = "TCP";
                tempPacket.sourceAddress = Convert.ToString(tcp.SourceAddress);
                tempPacket.destinationAddress = Convert.ToString(tcp.DestinationAddress);
                tempPacket.sourcePort = Convert.ToString(tcp.SourcePort);
                tempPacket.destinationPort = Convert.ToString(tcp.DestinationPort);
                tempPacket.packetMessage = Convert.ToString(tcp.Data);
                packetsList.Add(tempPacket);


                string[] row = { packetsList[countOfPacketCaptures].packetType, packetsList[countOfPacketCaptures].sourceAddress, packetsList[countOfPacketCaptures].destinationAddress, packetsList[countOfPacketCaptures].sourcePort, packetsList[countOfPacketCaptures].destinationPort, packetsList[countOfPacketCaptures].packetMessage };
                try {


                    listView1.Items.Add(packetsList[countOfPacketCaptures].packetType, packetsList[countOfPacketCaptures].sourceAddress, packetsList[countOfPacketCaptures].destinationAddress, packetsList[countOfPacketCaptures].sourcePort, packetsList[countOfPacketCaptures].destinationPort, packetsList[countOfPacketCaptures].packetMessage)

                    ; countOfPacketCaptures++;
                lblCapturesLabels.Text …
Run Code Online (Sandbox Code Playgroud)

c# listview

1
推荐指数
1
解决办法
1663
查看次数

尽管有关键字

notwithstanding关键字在Google Go中意味着什么?

go

21
推荐指数
2
解决办法
3238
查看次数

在GCC召集大会?

#include <stdlib.h>

static inline uint
xchg(volatile unsigned int *addr, unsigned int newval)
{
   uint result;
   asm volatile("lock; xchgl %0, %1" : "+m" (*addr), "=a" (result) : "1" (newval) : "cc");

return result;    
}
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我这段代码到底是做什么的吗?我的意思是我有一个想法或这个命令的部分."1"newval是输入,"= a"是清除其先前的值并更新它."m"用于内存操作,但我对此功能的功能感到困惑."+ m"标志有什么作用?这个函数是否像m = a那样; m = newval; 回来一个

c x86 gcc constraints inline-assembly

8
推荐指数
2
解决办法
845
查看次数

旋转UIViewController以抵消UIInterfaceOrientation中的更改

我一直在搜索这个问题,找不到任何可以帮助我的东西.

我有一个UIViewController包含在另一个UIViewController中.当父UIViewController旋转时,比如从Portrait到LandscapeLeft,我想让它看起来好像孩子没有旋转.也就是说.无论父母的方向如何,我都希望孩子与天空的方向相同.如果它在Portrait中有一个直立的UIButton,我希望按钮的右侧在UIInterfaceOrientationLandscapeLeft中"向上".

这可能吗?目前,我正在做这样的事情:

-(void) rotate:(UIInterfaceOrientation)fromOrientation: toOr:(UIInterfaceOrientation)toOrientation
{
    if(((fromOrientation == UIInterfaceOrientationPortrait) && (toOrientation == UIInterfaceOrientationLandscapeRight))
       || ((fromOrientation == UIInterfaceOrientationPortraitUpsideDown) && (toOrientation == UIInterfaceOrientationLandscapeLeft)))
    {

    }
    if(((fromOrientation == UIInterfaceOrientationLandscapeRight) && (toOrientation == UIInterfaceOrientationPortraitUpsideDown))
       || ((fromOrientation == UIInterfaceOrientationLandscapeLeft) && (toOrientation == UIInterfaceOrientationPortrait)))
    {

    }
    if(((fromOrientation == UIInterfaceOrientationPortrait) && (toOrientation == UIInterfaceOrientationLandscapeLeft))
       || ((fromOrientation == UIInterfaceOrientationPortraitUpsideDown) && (toOrientation == UIInterfaceOrientationLandscapeRight)))
    {

    }
    if(((fromOrientation == UIInterfaceOrientationLandscapeLeft) && (toOrientation == UIInterfaceOrientationPortraitUpsideDown))
       || ((fromOrientation == UIInterfaceOrientationLandscapeRight) && (toOrientation == UIInterfaceOrientationPortrait)))
    {

    }
    if(((fromOrientation == UIInterfaceOrientationPortrait) && (toOrientation …
Run Code Online (Sandbox Code Playgroud)

iphone uiviewcontroller uiview iphone-sdk-3.0 interface-orientation

1
推荐指数
1
解决办法
7927
查看次数

使用VBA与.Net自动化Excel的优点和缺点

我的任务是在Excel中创建一个可以从一些自定义函数/宏中受益的财务规划工具.

我最初的反应是使用VBA.我之前用它来驱动Excel(比如5年前).但我开始怀疑我是否会更好地使用VSTO.

有没有人有使用这两种技术的经验,可以列出优点和缺点,以便我可以评估哪种方法最好.

.net excel vba

13
推荐指数
1
解决办法
2万
查看次数

将bash变量管道化为awk并存储输出

为了说明我的问题,

TEST="Hi my name is John"
OUTP=`echo $TEST | awk '{print $3}'`
echo $OUTP
Run Code Online (Sandbox Code Playgroud)

我期望这样做是将$ TEST变量传递给awk并将第三个字存储到$ OUTP中.

相反,我得到"嗨:没找到",好像它期望输入是一个文件.但是,如果我只传递一个字符串而不是一个变量,则没有问题.什么是最好的方法来解决这个问题?

谢谢大家!

bash awk

8
推荐指数
2
解决办法
4万
查看次数

Windows和Native API中的系统调用?

最近我在*NIX操作系统中使用了很多汇编语言.我想知道Windows域名.


在linux中调用约定:

mov $SYS_Call_NUM, %eax
mov $param1 , %ebx
mov $param2 , %ecx
int $0x80
Run Code Online (Sandbox Code Playgroud)

而已.这就是我们应该如何在linux中进行系统调用.

在linux中引用所有系统调用:

关于哪个$ SYS_Call_NUM以及哪些参数我们可以使用这个参考:http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html

官方参考:http://kernel.org/doc/man-pages/online/dir_section_2.html


在Windows中调用约定:

???

Windows中所有系统调用的引用:

???

非官方:http://www.metasploit.com/users/opcode/syscalls.html,但除非我知道调用约定,否则如何在汇编中使用它们.

官方:???

  • 如果你说,他们没有记录它.那么如何在不知道系统调用的情况下为windows编写libc?如何进行Windows程序集编程?至少在驱动程序编程中需要了解这些.对?

现在,与所谓的Native API有什么关系?是Native APISystem calls for windows两者都是指同一件事的不同术语吗?为了证实我将这些来自两个非官方来源进行了比较

系统调用:http://www.metasploit.com/users/opcode/syscalls.html

Native API:http://undocumented.ntinternals.net/aindex.html

我的观察:

  1. 所有系统调用都以字母开头,Nt其中Native API由许多不以字母开头的函数组成Nt.
  2. System Call of windows是.的子集Native API.系统调用只是Native API的一部分.

任何人都可以证实并解释.

编辑:

还有另一个答案.这是第二个答案.我真的很喜欢它,但我不知道为什么回答者已删除它.我请他转发他的答案.

linux windows assembly kernel nt-native-api

24
推荐指数
2
解决办法
1万
查看次数

如何从Windows Phone 7中的本地文件系统中选择文件

我正在尝试选择一些文件在Windows Phone 7中(在模拟器中)上传,并且任何OpenFileDialog的ShowDialog尝试都会导致安全异常.打开文件对话框是从按钮单击的事件调用,但我得到了一个

SecurityException

[FileDialog_ActiveScripting]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=3.0.40806.0&File=System.Windows.dll&Key=FileDialog_ActiveScripting
Run Code Online (Sandbox Code Playgroud)

在OpenFileDialog.ShowDialog的Silverlight版本中查找SecurityException指出错误是:

Active Scripting in Internet Explorer is disabled.

-or-

The call to the ShowDialog method was not made from user-initiated code.
Run Code Online (Sandbox Code Playgroud)

任何人都对Windows Phone 7中的OpenFileDialog和ShowDialog有好运吗?

silverlight windows-phone-7

1
推荐指数
2
解决办法
3039
查看次数

播放MediaElement后,我该如何再次播放?

我在Silverlight应用程序中有一个名为TestAudio的变量MediaElement变量.

单击按钮时,它会正确播放音频.

但是当我再次单击该按钮,它不会播放音频.

如何让MediaElement第二次播放?

下面没有尝试将位置恢复为0工作:

private void Button_Click_PlayTest(object sender, RoutedEventArgs e)
{
    //TestAudio.Position = new TimeSpan(0, 0, 0);
    //TestAudio.Position = TestAudio.Position.Add(new TimeSpan(0, 0, 0));
    //TestAudio.Position = new TimeSpan(0, 0, 0, 0, 0);
    //TestAudio.Position = TimeSpan.Zero;

    TestAudio.Play();
}
Run Code Online (Sandbox Code Playgroud)

audio silverlight wpf mp3 mediaelement

2
推荐指数
1
解决办法
7726
查看次数

是否可以在不使用偏移量的情况下将指针存储在共享内存中?

当使用共享存储器时,每个进程可以将共享区域映射到其相应地址空间的不同区域.这意味着在共享区域中存储指针时,需要将它们存储为共享区域起点的偏移量.不幸的是,这使得原子指令的使用变得复杂(例如,如果您正在尝试编写无锁算法).例如,假设您在共享内存中有一堆引用计数节点,由单个编写器创建.写入器周期性地原子地更新指针"p"以指向具有正引用计数的有效节点.读者希望原子地写入'p',因为它指向一个节点(结构)的开头,其第一个元素是引用计数.由于p始​​终指向有效节点,因此增加引用计数是安全的,并且可以安全地取消引用"p"并访问其他成员.但是,这一切只有在所有内容都在同一地址空间时才有效.如果节点和'p'指针存储在共享内存中,则客户端会遇到竞争条件:

  1. x =读p
  2. y = x +偏移量
  3. 在y处增加refcount

在步骤2期间,p可能会改变,x可能不再指向有效节点.我能想到的唯一解决方法是以某种方式迫使所有进程就共享内存映射的位置达成一致,以便在mmap'd区域中存储真实指针而不是偏移量.有没有办法做到这一点?我在mmap文档中看到了MAP_FIXED,但我不知道如何选择一个安全的地址.

编辑:使用内联汇编和x86上的'lock'前缀也许可以建立一个"增量ptr X,偏移量Y乘以值Z"?其他架构的等价选项?没有写过很多装配,不知道是否存在所需的指令.

multithreading mmap atomic shared-memory race-condition

8
推荐指数
1
解决办法
5018
查看次数