人
我想在我编写c ++的GUI程序中传递argv参数,我的程序不是黑屏控制台,但它是一个GUI。 例如我的程序是AAA.exe,我想传递一个命令,如" AAA.exe doThing"我该怎么办?非常感谢你们。
答案 0 :(得分:3)
答案 1 :(得分:1)
如果您使用VS,则可以轻松使用__argc and __argv。
这些变量由CRT自动填充。变量以MBCS / ANSI版本和Unicode版本提供。 __argv是MBCS / ANSI版本,而__wargv是unicode版本。
要使用它们,我们只需要包含stdlib.h。当你包含TCHAR.h时,还有一个__targv版本。
答案 2 :(得分:-2)
提出了以下答案,它经过测试并且可以很好地用作箭头。 在WinMain块中添加了此代码。
using (var context = new StoreDbContext())
{
// Retrieve entity by id
// Answer for question #1
var entity = context.Products.FirstOrDefault(item => item.ProductID == id);
// Validate entity is not null
if (entity != null)
{
// Answer for question #2
// Make changes on entity
entity.UnitPrice = 49.99m;
entity.Description = "Collector's edition";
// Update entity in DbSet
context.Products.Update(entity);
// Save changes in database
context.SaveChanges();
}
}